Skip to content

Instantly share code, notes, and snippets.

@fairchild
Forked from retr0h/gist:98308
Created July 20, 2009 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fairchild/150855 to your computer and use it in GitHub Desktop.
Save fairchild/150855 to your computer and use it in GitHub Desktop.
content_type filter for sinatra
CONTENT_TYPES = {:html => 'text/html', :css => 'text/css', :js => 'application/javascript'}
before do
request_uri = case request.env['REQUEST_URI']
when /\.css$/ : :css
when /\.js$/ : :js
else :html
end
content_type CONTENT_TYPES[request_uri], :charset => 'utf-8'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment