Posted 27 days ago. Visible to the public.

Convert curl commands to ruby code

curl-to-ruby is a handy tool that converts your curl command to ruby code that uses the Net::HTTP library.

Example

Copy
curl -X POST -d "grant_type=password&email=email&password=password" localhost:3000/oauth/token

will output to:

Copy
require 'net/http' require 'uri' uri = URI.parse("http://localhost:3000/oauth/token") request = Net::HTTP::Post.new(uri) request.set_form_data( "email" => "email", "grant_type" => "password", "password" => "password", ) req_options = { use_ssl: uri.scheme == "https", } response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| http.request(request) end # response.code # response.body
Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Avatar
Jakob Scholz
Last edit:
27 days ago
by Jakob Scholz
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Jakob Scholz to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more