If you’re using faraday
for your http-related interactions, you can now use httpx
seamlessly as a backend.
For that, you just have to require "httpx/adapters/faraday"
and set :httpx
as the adapter.
Below is an example of using httpx
with the stripe-ruby
gem, which uses faraday
(and the net-http-pipeline
backend) by default:
require "httpx/adapters/faraday"
require "stripe"
Stripe.api_key = "your key"
conn = Faraday.new do |builder|
builder.use Faraday::Request::Multipart
builder.use Faraday::Request::UrlEncoded
builder.use Faraday::Response::RaiseError
builder.adapter :httpx
end
client = Stripe::StripeClient.new(conn)
Stripe::Charge.create({
amount: 100,
currency: "usd",
source: "src_123"
}, {client: client})
The faraday
adapter uses the compression
and persistent
plugins by default. If you know of any cases where this might be an impediment, or you’d like to suggest more default plugins for it, do let me know.
Next: Datadog