I was wondering how I could set a custom user-agent for all of my API requests from ActiveResource? Basically, I want to identify my application when ever I hit someone's API from ActiveResource.
Thanks! Tom
I was wondering how I could set a custom user-agent for all of my API requests from ActiveResource? Basically, I want to identify my application when ever I hit someone's API from ActiveResource.
Thanks! Tom
Disclaimer - I haven’t tried this, but it should work:
class Person < ActiveResource::Base self.site = “http://api.people.com:3000/”
self.headers[“User-agent”] = “MyUser/agent v1.0”
end
ActiveResource::Base#headers returns a hash, so it should be as easy as that.
http://api.rubyonrails.org/classes/ActiveResource/Base.html#M000890
Cheers,
Andy