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

consider switching away from typhoeus? #63

Open
jjb opened this issue Mar 22, 2023 · 0 comments
Open

consider switching away from typhoeus? #63

jjb opened this issue Mar 22, 2023 · 0 comments

Comments

@jjb
Copy link

jjb commented Mar 22, 2023

Hi - thanks for maintaining this gem!

Would you consider switching away from typhoeus and using faraday with stdlib http library instead? Or maybe some other ruby-only client?

my general goal is to reduce dependencies

another specific goal is to not need to build ethon and have curl libraries available

here's a starting point i use for faraday clients, in case it's helpful

if you prefer not to do this and/or need the performance of typhoeuous, no worries and feel free to close this! 😅

require 'faraday_middleware'

conn = Faraday.new("https://api.service.com") do |f|
  f.adapter Faraday.default_adapter
  f.authorization :Bearer, API_KEY
  f.request :json # encode req bodies as JSON
  f.response :json # decode response bodies as JSON
  f.request :retry # retry transient failures
end

resp = conn.post("/things") do |req|
  req.body = body_params # body_params is a ruby hash
end

# resp.body is now a ruby hash
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

No branches or pull requests

1 participant