allow viewing request headers (#8)
* allow viewing request headers * text/plain output for headers
This commit is contained in:
parent
1f3d5b79af
commit
5ce019b742
1 changed files with 13 additions and 0 deletions
13
config.ru
13
config.ru
|
@ -11,6 +11,19 @@ map '/lobster' do
|
||||||
run Rack::Lobster.new
|
run Rack::Lobster.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
map '/headers' do
|
||||||
|
headers = proc do |env|
|
||||||
|
[200, { "Content-Type" => "text/plain" }, [
|
||||||
|
env.select {|key,val| key.start_with? 'HTTP_'}
|
||||||
|
.collect {|key, val| [key.sub(/^HTTP_/, ''), val]}
|
||||||
|
.collect {|key, val| "#{key}: #{val}"}
|
||||||
|
.sort
|
||||||
|
.join("\n")
|
||||||
|
]]
|
||||||
|
end
|
||||||
|
run headers
|
||||||
|
end
|
||||||
|
|
||||||
map '/' do
|
map '/' do
|
||||||
welcome = proc do |env|
|
welcome = proc do |env|
|
||||||
[200, { "Content-Type" => "text/html" }, [<<WELCOME_CONTENTS
|
[200, { "Content-Type" => "text/html" }, [<<WELCOME_CONTENTS
|
||||||
|
|
Loading…
Reference in a new issue