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

Adapter for HTTP.rb #775

Closed
PandaWhisperer opened this issue Feb 23, 2018 · 6 comments
Closed

Adapter for HTTP.rb #775

PandaWhisperer opened this issue Feb 23, 2018 · 6 comments
Labels
info Generic question on how to use Faraday

Comments

@PandaWhisperer
Copy link

Summary

Recently found out about HTTP - The Gem! a.k.a. HTTP.rb. Yet another HTTP client for Ruby, but looks like a pretty neat one.

Would be cool if Faraday had an adapter for it.

Details

I'm willing to help with that, in fact, I'm considering writing it myself. Would just need a few pointers to get started, and answers to the following questions:

  • How to write an adapter? Is there a guide, or a specific implementation that's good to learn from?
  • Where to submit the pull request? HTTP.rb? Faraday? Both?
@iMacTia
Copy link
Member

iMacTia commented Feb 24, 2018

Hi @PandaWhisperer and thanks for the interest in Faraday!

Up until now, adapter have been kept in Faraday and maintained by the core team.
However, we realised this caused some issues, so have decided to move them outside.

My preferred solution is to have a dedicated gem (e.g. faraday-http), but there are instances where the adapter have been integrated inside the client gem (e.g. typhoeus).
You’re free to choose the one you prefer, but the former is usually the best option unless you’re a maintainer of the client gem.

Regarding the implementation, I recently gave some advises on how to build another adapter. You can find them (together with a link to the adapter code) in #766.

I’m also in the process of rewriting tests using RSpec and the idea is to allow external gems to integrate those into their tests pipeline. But that’s not a short term thing 😅

I hope this is all useful but please let me know if you need anything else 👍!

@PandaWhisperer
Copy link
Author

Hey @iMacTia. I had some time and hacked together a basic adapter. You can see a pull request here (I didn't send it to the main repo). Basic features are supported and tested. If you have a minute I would appreciate your feedback.

NOTE: this was just for fun, I don't actually NEED this right now. But if anyone does and would like to wrap it into a gem, please LMK.

@iMacTia
Copy link
Member

iMacTia commented Mar 9, 2018

Hi @PandaWhisperer and thanks for taking the time to work on this!
I had a quick look and the PR looks like a good starting point 👍
As you pointed out already, I doubt the current implementation offers support for SSL or compression, but considering it was developed for fun in the spare time, I would be happy with the result 😄

The whole idea behind v1.0 is to make dead-simple the process of creating a new adapter so that people like you (the community!) can contribute to Faraday without directly depending on the core team.
An important, currently undergoing, task to reach that goal is to have tests simplified and available to be executed from external adapter/middleware gems.

I'm currently focused on that and you can see the progress in this branch.

Once that's completed and merged, we can think of using your adapter as a test desk for it 👍

@iMacTia iMacTia added the info Generic question on how to use Faraday label Aug 21, 2018
@iMacTia
Copy link
Member

iMacTia commented Nov 27, 2018

Hi @PandaWhisperer 👋
After some painful months and a lot of refactoring, tests in 1.0 have now been converted to RSpec 🎉 !
As part of this, I've created a set of "shared examples" that describes how an adapter should work.

Next step would be to make these tests available for external gems so that they can test changes against the Faraday core.

If you're still working on your HTTP client and would like to give it a try, please do let me know 👍

@iMacTia
Copy link
Member

iMacTia commented Mar 8, 2019

@PandaWhisperer We're now getting closer to v1.0 and adapters can now live in their own repos.
I took the freedom of building a gem out of the adapter you wrote, you can find the main PR here: lostisland/faraday-http#1

This is just a proof of concept, but it may go on becoming Faraday 1.0's first official external adapter ❤️

If you're still interested in that adapter and have some time, I'd happily add you as a collaborator in that project so you can maintain and improve it over time.

@iMacTia iMacTia closed this as completed Mar 8, 2019
@iMacTia
Copy link
Member

iMacTia commented May 8, 2020

@PandaWhisperer faraday-http first release just happened, and it's mostly thanks to your work last year: https://rubygems.org/gems/faraday-http 🎉

In case you're still planning on using it and you're interested, I'd like to renew the invite on adding you as a collaborator in that repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info Generic question on how to use Faraday
Projects
None yet
Development

No branches or pull requests

2 participants