Skip to content

Instantly share code, notes, and snippets.

@scharfie
Last active February 8, 2019 14:24
Show Gist options
  • Save scharfie/c00760385c8ef1ffd1a67acb40bf1f86 to your computer and use it in GitHub Desktop.
Save scharfie/c00760385c8ef1ffd1a67acb40bf1f86 to your computer and use it in GitHub Desktop.
# run with: rackup --host 0.0.0.0 dumper.ru
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem "shotgun"
gem "rack"
end
require 'json'
require 'pp'
module Colorize
def colorize(color_code); "\e[#{color_code}m#{self}\e[0m"; end
end
class Dumper
def self.call(env)
request = Rack::Request.new(env)
result = {
params: request.params
}
body = JSON.pretty_generate(result)
body.extend Colorize
$stdout.puts body.colorize(32)
[200, { "Content-Type" => "text/json" }, [body]]
end
end
run Dumper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment