Closed ne006 closed 9 months ago
Hi @ne006 and thank you for proposing this contribution.
I like the idea and I've heard similar requests in the past as well.
However, please note that as stated in the README faraday_middleware
is now deprecated, so we're not accepting new feature PRs against it.
The EncodeJson
and ParseJson
middleware are now shipped out-of-the-box with Faraday, so if you'd like you can "move" this contribution directly to them 👍 . See the json request and json response middleware in Faraday.
If you reopen this PR against those, I'll be happy to review. Based on a quick review, I can say the PR looks good and has good test coverage, but we'd require the documentation to be updated as well before it can be merged, especially around the functionality of passing a class/method pair I see you implemented. You can find the json middleware (both request and response) documentation here.
Thank you again for the contribution and I look forward to reviewing it once moved on Faraday. For now, I'll be closing this PR for the reason mentioned at the beginning.
By default
FaradayMiddleware::EncodeJson
andFaradayMiddleware::ParseJson
usesjson
to encode/decode JSON data, although there are gems likeoj
which do the job faster than Ruby's built-injson
.This implementation allows to pass
encoder
option toFaradayMiddleware::EncodeJson
anddecoder
option to pass inparser_options
toFaradayMiddleware::ParseJson