Rack’s env
Ever wonder what the “env” looked like in Rack? Run this code via Ruby and point your browser to http://localhost:4000 to find out.
class SuperMicroApp
def call(env)
[200, {'Content-Type' => 'text/html'}, pretty_env(env) ]
end
def pretty_env(hash)
pretty_hash = ""
hash.each do |k,v|
pretty_hash += "#{k}: #{v} --> #{v.class}<br />"
end
pretty_hash += "<br /><br />"
hash["REQUEST_PATH"].split("/").each do |r|
pretty_hash += "#{r=="" ? "none" : r}<br />"
end
return pretty_hash
end
end
require 'rubygems'
require 'rack'
Rack::Handler::Thin.run(SuperMicroApp.new, :Port => 4000)