forked from patricksimpson/gem-fetcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.ru
37 lines (30 loc) · 807 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
require './bin/fetch-gems'
require 'rack/rewrite'
use Rack::Rewrite do
def is_a_review_app?(rack_env)
rack_env['SERVER_NAME'].end_with? 'herokuapp.com'
end
def is_local?(rack_env)
rack_env['SERVER_NAME'].end_with? 'localhost'
end
r301 %r{.*}, 'https://gems.sparkbox.com/', :scheme => 'http'
r301 %r{.*}, 'https://gems.sparkbox.com$&', :if => Proc.new {|rack_env|
rack_env['SERVER_NAME'] != 'gems.sparkbox.com' &&
!is_a_review_app?(rack_env) &&
!is_local?(rack_env)
}
end
use Rack::Static,
:urls => ["/images", "/js", "/css", "/data"],
:root => "public"
run lambda { |env|
GemGetter.fetch
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/index.html', File::RDONLY)
]
}