class RequestFormatter
Public Class Methods
new(request)
click to toggle source
# File lib/see_your_requests/request_formatter.rb, line 2 def initialize(request) @request = request end
Public Instance Methods
print_body()
click to toggle source
# File lib/see_your_requests/request_formatter.rb, line 31 def print_body if @request.body.size > 0 puts 'Request body:' puts @request.body.read end end
print_http_headers()
click to toggle source
# File lib/see_your_requests/request_formatter.rb, line 18 def print_http_headers formatted_headers = {} http_headers = @request.env.select { |k, v| k =~ /^HTTP_.*/ } puts 'HTTP Headers:' http_headers.each do |k, v| formatted_header = k.gsub(/^HTTP_/, "") formatted_headers[formatted_header] = v puts "\t#{ formatted_header }: #{ v }" end formatted_headers.to_s end
print_method()
click to toggle source
# File lib/see_your_requests/request_formatter.rb, line 13 def print_method method = @request.env["REQUEST_METHOD"] puts "Request method: #{ method }" end
print_request()
click to toggle source
# File lib/see_your_requests/request_formatter.rb, line 6 def print_request puts "\nRequest received at #{ Time.now }" print_method print_http_headers print_body end