Skip to content

Instantly share code, notes, and snippets.

@cloudrck
Forked from aportnov/Sinatra request headers helper
Last active February 20, 2017 11:19
Show Gist options
  • Save cloudrck/38e6b53891671f6497fd to your computer and use it in GitHub Desktop.
Save cloudrck/38e6b53891671f6497fd to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sinatra'
helpers do
def request_headers
env.inject({}){|acc, (k,v)| acc[$1.downcase] = v if k =~ /^http_(.*)/i; acc}
end
end
get '/headers' do
puts request_headers.inspect
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment