-
Notifications
You must be signed in to change notification settings - Fork 35
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
add faraday connection options without breaking api #80
Conversation
Just found that I can use the Hyperclient.new('https://api.example.com/') do |client|
client.connection do |conn|
conn.ssl.update(verify: false)
conn.authorization :Bearer, 'ioP_pcKLhB4NLMGKMM6B40rwkBC.5o2JpsnBHhmKs4QAExG'
end
end But I still think it would be nice to set the Faraday options in the |
I'm down with this, but it needs a test, README and CHANGELOG updates, please. |
|
if block_given? | ||
fail ConnectionAlreadyInitializedError if @connection | ||
if options[:default] | ||
if @faraday_options.delete(:default) == false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you should be delete
ing items from here because this is a hash passed from the outside. Also comparing to false
is probably a bad idea. If you need to check whether the value is present at all, use key?
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because :default
is of no use for Faraday. But yeah, I'm not exactly cool with it either..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use @faraday_options = options.dup
though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are going to delete
, yes.
This is nice work. See my comment(s) above. Don't forget CHANGELOG, README and please squash the commits if appropriate. |
Working on the README and CHANGELOG as we speak ;) |
The weird whitespace in |
default is implicit, non default explicit update rubocop dependency update README and CHANGELOG
@@ -2,10 +2,11 @@ | |||
|
|||
* Your contribution here. | |||
|
|||
### 0.7.0-pre (December 1, 2014) | |||
### 0.7.0 (December 2, 2014) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, I usually just keep these things under Next. That's because there's no actual -pre release, so it may be confusing for someone reading it. It's no big deal.
Merging. |
add faraday connection options without breaking api
SSL options can only be passed to Faraday on initialization. So I've added a
connection_options
property which is passed to Faraday directly.I think it would be better if the options hash of
connection
would be passed to Faraday, then we can simply write:But this means the use
options[:default]
should be changed to something like a property of the client, and thus breaking the API.