forked from thoughtbot/fistface
/
app.rb
25 lines (22 loc) · 878 Bytes
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'rubygems'
require 'bundler'
require 'open-uri'
Bundler.require
class App < Sinatra::Base
set :app_file, __FILE__
before do
headers 'Cache-Control' => 'public, max-age=31536000',
'Expires' => (Time.now + 31536000).httpdate,
'Access-Control-Allow-Origin' => '*'
end
get '/:font_face' do
headers['Content-Type'] = case params[:font_face]
when /\.ttf$/ then 'font/truetype'
when /\.otf$/ then 'font/opentype'
when /\.woff$/ then 'font/woff'
when /\.eot$/ then 'application/vnd.ms-fontobject'
when /\.svg$/ then 'image/svg+xml'
end
send_file open("#{ENV['S3_URL']}/#{params[:font_face]}")
end
end