Open stefan-pdx opened 11 years ago
Hey @slnovak, I'm also wondering about question 1.
About question 2 & 3, you can write a middleware like this (not tested):
based on Faraday docs
# her.rb
class QueryInjector < Faraday::Middleware
def call(env)
token = RequestStore.store[:token] # or any method to get your token
# env[:url] is a URI object
env[:url].query = "f=json?token=#{token}"
# You can also change headers
# env[:request_headers]['header']
@app.call(env)
end
end
Her::API.setup ... do |c|
c.use QueryInjector
c.use Faraday::Request::UrlEncoded
...
end
Hey guys. I'm really stoked to have come across Her. I look forward to helping out a bit in building out new features.
Unfortunately, I'm dealing with an enterprise-y API that isn't entirely REST-ful. There are two challenges that I've come across:
/items
. However, to create a new item, I have to make a POST to/addItems
. Is it possible to override an action path to a different URL?/items/1?f=json
. Is the best way to represent this via theresource_path
method? I.e.,resource_path "items/:id?f=json"
?Thanks!