-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.ru
42 lines (36 loc) · 978 Bytes
/
config.ru
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# This file is used by Rack-based servers to start the application.
ENVIRONMENT = ENV['RACK_ENV'] || 'development'
require './boot'
### Routes
map '/' do
run proc { |env|
if env['PATH_INFO'] == '/'
[200, { 'Content-Type' => 'text/html' }, [SprocketsApp['index.html'].to_s]]
else
SprocketsApp.call(env)
end
}
end
map '/specs' do
run proc { |env|
if env['PATH_INFO'] == ''
[200, { 'Content-Type' => 'text/html' }, [SprocketsApp['run.html'].to_s]]
else
SprocketsApp.call(env)
end
}
end
map '/mocks/twitter' do
run proc { |env|
req = Rack::Request.new(env)
file_name = req.params.values_at('fixtureName', 'page', 'max_id').join('_')
file_path = ROOT.join('spec', 'fixtures', file_name)
if File.exists?(file_path)
puts "reading file at #{file_path}"
[200, { 'Content-Type' => 'text/javascript' }, [File.read(file_path)]]
end
}
end
map "/tzdata" do
run Rack::File.new(TZDATA_DIR)
end