-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Labels
Description
When passing a block to client.connection without the default: false option, adding any middleware will cause a warning:
api = Hyperclient.new('https://grape-with-roar.herokuapp.com/api') do |client|
client.connection do |conn|
conn.request :retry, max: 10, interval: 1.0, interval_randomness: 0.5
end
end
api.splines
#=> WARNING: Unexpected middleware set after the adapter. This won't be supported from Faraday 1.0.This warning was introduced in lostisland/faraday#685. We are seeing it here because the default_faraday_block, which adds the adapter, always runs before the custom block.
As a workaround I am specifying default: false and then copying in the default_faraday_block into my custom block so I can put things in the correct order:
api = Hyperclient.new('https://grape-with-roar.herokuapp.com/api') do |client|
client.connection(default: false) do |conn|
conn.use Faraday::Response::RaiseError
conn.use FaradayMiddleware::FollowRedirects
conn.request :hal_json
conn.response :hal_json, content_type: /\bjson$/
conn.request :retry, max: 10, interval: 1.0, interval_randomness: 0.5
conn.adapter :net_http
conn.options.params_encoder = Faraday::FlatParamsEncoder
end
end
api.splinesFaraday Version: 0.15.4
Hyperclient Version: 0.9.0
purinkle