Merged
requested to merge github/fork/ykitamura-mdsol/ruby-enhance-faraday-middleware-support into master
Created by: ykitamura-mdsol
Thanks to @johngallagher Faraday middlewares are configurable now:
- #10495
In this PR, I'd like to enhance the Faraday middleware support to be able to call the methods to push onto the various positions in the stack (insert
, insert_before
, insert_after
, swap
, and delete
) and also to be able to pass a block to the methods.
Usage
PetstoreAPI.configure do |config|
config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503])
config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug })
config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false)
config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 })
config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger) })
config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware)
:
PR checklist
-
Read the contribution guidelines. -
Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community. -
Run the following to build the project and update samples: ./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh
./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH. -
File the PR against the correct branch: master
(6.1.0) (minor release - breaking changes with fallbacks),7.0.x
(breaking changes without fallbacks) -
If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.