Posted 4 months 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.


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

will output to:

require 'net/http' require 'uri' uri = URI.parse("http://localhost:3000/oauth/token") request = 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

By refactoring problematic code and creating automated tests, makandra can vastly improve the maintainability of your Rails application.

Owner of this card:

Jakob Scholz
Last edit:
4 months 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