Skip to content

Instantly share code, notes, and snippets.

@migimunz
Created May 15, 2015 13:40
Show Gist options
  • Save migimunz/bef02ed174c42e2080c3 to your computer and use it in GitHub Desktop.
Save migimunz/bef02ed174c42e2080c3 to your computer and use it in GitHub Desktop.
A small sinatra app that just prints the request details it gets. Useful for debugging clients and reverse proxies.
require 'sinatra/base'
require 'pp'
class HttpDebug < Sinatra::Base
set :port, ARGV[0] || 8001
set :logging, false
[:get, :put, :post, :patch, :delete, :head, :link, :unlink, :options].each do |method|
send(method, '*') do
puts "#{method.to_s.upcase} #{request.path}"
puts "Full URL: #{request.url}"
puts "Params: #{pp params}"
if !request.content_length.nil?
puts "Body:"
pp request.body
puts "-------------"
end
puts ''
200
end
end
end
HttpDebug.run!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment