fairchild (owner)

Fork Of

Revisions

gist: 150855 Download_button fork
public
Description:
content_type filter for sinatra
Public Clone URL: git://gist.github.com/150855.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
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