-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose Faraday's options for API wrapper #4
Comments
If I'm understanding that correctly (sorry, new to the Like this, where
or specify options via
Maybe if there was a
It might look a little like:
I'd like to give it a shot, but I'm not exactly sure how I would add the request headers to it from here. It seems fairly straightforward until I get deep into the |
Hey, thanks for your interest! In fact, this particular issue is pretty simple:
But, what are you assumed, is also necessary feature of passing some parameter as a header # ...somewhere inside API description
param :jwt_token, format: ->(token) { "Bearer: #{@jwt_token}" }, header: 'Authorization' ^ the last argument says it should be passed as an auth.header instead of get param. client = SomeApiClient.new(jwt_token: "some_token")
client.some_method If you are interested in the latter (passing headers), I'd be happy to see a PR (and help you with it). Where you start to look is |
Thanks @zverok. I might give it a go. It seems like it could work. I'll use the params in the meantime. Thanks! |
Running in the same issue, which is three-fold:
|
I'd add a 4th item that initializing the connection would ideally be in its own method. Right now its in |
Let me be honest: I am in the middle of NaNoWriMo right now. It requires absolutely unprecedented amount of energy and attention. But I am VERY happy somebody finally found this library useful, and I pinky swear that first thing in December I will be back to all the old issues and unresolved PRs and generally review the code and architecture and make a lot of decisions. Does it work for you?.. |
I hope the NaNoWriMo went well. |
@zverok Thanks! Will you be sharing the novel? |
Phew, sorry guys, finally back :) Now I am all yours.
@marcandre I believe the most reasonable change would having ONE faraday object per whole API structure, and provide direct access to it via (at least): api = MyTLAWAPI.new(...) do |faraday|
faraday.use SomeMiddleware
end Moreover, it is probably useful to have in API definition DSL some block like setup_faraday do |faraday|
faraday.use SomeMiddleware
end WDYT? |
The idea is: Faraday allows to setup a lot of options (setup logger, timeouts, request headers), change adapter (backend HTTP library), add middleware (for example, add response caching). Some of this can be useful for TLAW users. Proposed syntax:
The text was updated successfully, but these errors were encountered: