Skip to content
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 support for both Faraday 1.x and 2.x #133

Closed
wants to merge 1 commit into from
Closed

Add support for both Faraday 1.x and 2.x #133

wants to merge 1 commit into from

Conversation

nickcampbell18
Copy link
Contributor

Changelog: https://github.com/lostisland/faraday/blob/main/UPGRADING.md#faraday-20

To support Faraday 2.x, the faraday_middleware library is no longer required for sending/receiving JSON bodies, and each individual adapter is shipped as a separate gem (e.g. faraday-patron).

Since it's quite hard to update Faraday everywhere (because it is a dependency of many different gems), we should support both versions in Spyke to allow users to upgrade Faraday on their terms.

Changelog: https://github.com/lostisland/faraday/blob/main/UPGRADING.md#faraday-20

To support Faraday 2.x, the `faraday_middleware` library is no longer
required for sending/receiving JSON bodies, and each individual adapter
is shipped as a separate gem (e.g. faraday-patron).

Since it's quite hard to update Faraday everywhere (because it is a
dependency of many different gems), we should support both versions in
Spyke to allow users to upgrade Faraday on their terms.
@balvig
Copy link
Owner

balvig commented Mar 30, 2022

Hello @nickcampbell18!

Thanks so much for kicking this off. 💪

Having tested out Spyke with Faraday 2.x locally, it seems like maybe there is quite a few other places that will need tweaking... 😓 I have a WIP branch at https://github.com/balvig/spyke/compare/jb/faraday-support that isn't working yet, will probably take a bit more time/effort as it looks like at least need to address:

  • Different style of writing middleware
  • External middleware required for processing multipart requests

@nickcampbell18
Copy link
Contributor Author

I'm getting flashbacks of the Faraday 1.x upgrade 😭 If it helps, for the middleware namespace, I found it was simple to swap out the parent class, and the on_complete methods still run: https://github.com/zaikio/zaikio-client-helpers/pull/7/files#diff-580481e9c0df0e54f8251677d84b9445637c095666438baf9833bb613b0bb49dR14-R31

But yeah, multipart...fun 🎉

@balvig
Copy link
Owner

balvig commented Apr 14, 2022

@nickcampbell18 after a bit of fiddling around, I think I have it working in #135.
If you have a chance to test it out, let me know how it goes! 🙏

@nickcampbell18 nickcampbell18 deleted the faraday-2.x branch April 20, 2022 08:43
balvig added a commit that referenced this pull request Apr 26, 2022
## What

- Adds support for Faraday >= 2.0
- Preserves support for Faraday < 2.0
- Updates documentation to cover both versions
- Adds Faraday versions to test matrix
- Closes #133
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants