-
Notifications
You must be signed in to change notification settings - Fork 167
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
Faraday retry middleware #490
Changes from 7 commits
e506adc
79c6702
3d9934b
02e6443
2e93c98
c8deae8
1a75767
980dcd0
eb673a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,10 @@ def initialize_client( | |
end | ||
end | ||
|
||
def with_faraday_config(&block) | ||
@faraday_client = create_faraday_client(&block) | ||
end | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've changed my approach following your suggestion to expose this method which takes a block that yields the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice 👍 |
||
def method_missing(method_sym, *args, &block) | ||
if discovery_needed?(method_sym) | ||
discover | ||
|
@@ -313,6 +317,8 @@ def create_faraday_client(url = nil) | |
if @auth_options[:username] && @auth_options[:password] | ||
connection.basic_auth(@auth_options[:username], @auth_options[:password]) | ||
end | ||
# hook for adding custom faraday configuration | ||
yield(connection) if block_given? | ||
connection.use(FaradayMiddleware::FollowRedirects, limit: @http_max_redirects) | ||
connection.response(:raise_error) | ||
end | ||
|
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.
it looks like this could be called multiple times, but it can't ... so maybe call it
replace_faraday_config
... and would seem more intuitive to specify this during initalization anyway like
configure_faraday: -> {|c| stuff }