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.
Example
Copycurl -X POST -d "grant_type=password&email=email&password=password" localhost:3000/oauth/token
will output to:
Copyrequire '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
By refactoring problematic code and creating automated tests, makandra can vastly improve the maintainability of your Rails application.