Created
July 17, 2011 05:46
-
-
Save noomerikal/e39e1627dfad9a0384e3 to your computer and use it in GitHub Desktop.
sinatra request headers helper
This file contains hidden or 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
| 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