module Faraday::DetailedLogger::CurlFormatter

Public Class Methods

request(env) click to toggle source
# File lib/faraday/detailed_logger/curl_formatter.rb, line 6
def self.request(env)
  "#{env[:method].upcase} #{env[:url]}"
end
request_body(env) click to toggle source
# File lib/faraday/detailed_logger/curl_formatter.rb, line 10
def self.request_body(env)
  curl_output(env[:request_headers], env[:body]).inspect
end
response(env) click to toggle source
# File lib/faraday/detailed_logger/curl_formatter.rb, line 14
def self.response(env)
  "HTTP #{env[:status]}"
end
response_body(env) click to toggle source
# File lib/faraday/detailed_logger/curl_formatter.rb, line 18
def self.response_body(env)
  curl_output(env[:response_headers], env[:body]).inspect
end

Private Class Methods

curl_output(headers, body) click to toggle source
# File lib/faraday/detailed_logger/curl_formatter.rb, line 24
def self.curl_output(headers, body)
  string = headers.to_a.sort_by(&:first).map { |k, v| "#{k}: #{v}" }.join("\n")
  string + "\n\n#{body}"
end