Last active
February 8, 2019 14:24
-
-
Save scharfie/c00760385c8ef1ffd1a67acb40bf1f86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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