Faraday: Adapter for HTTP.rb

Created on 23 Feb 2018  ·  6Comments  ·  Source: lostisland/faraday

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?
info

Most helpful comment

@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

All 6 comments

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 👍!

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.

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 👍

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 👍

@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: https://github.com/lostisland/faraday-http/pull/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.

@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

Was this page helpful?
0 / 5 - 0 ratings