This middleware logs your HTTP requests as CURL compatible commands so you can share the calls you're making with someone else or keep them for debugging purposes.
Add this line to your application's Gemfile:
gem 'faraday_curl'
And then execute:
$ bundle
Or install it yourself as:
$ gem install faraday_curl
This gem provides a request middleware so you have to require and declare it at your Faraday middleware stack:
require 'faraday_curl'
require 'logger'
domain = "http://example.com/"
logger = Logger.new(STDOUT)
Faraday.new(:url => domain) do |f|
f.request :url_encoded
f.request :curl, logger, :warn
f.adapter Faraday.default_adapter
end
The middleware takes a logger
object and a log level
parameter and it will call the log level declared with the CURL compatible command to print it. The request should be the last request middleware to make sure the body is already a string.
- Fork it ( http://github.com/mauricio/faraday-curl/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request