-
Notifications
You must be signed in to change notification settings - Fork 14
/
config.ru
40 lines (33 loc) · 1.03 KB
/
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
require 'rubygems'
require 'bundler/setup'
Bundler.require(:default, ENV['RACK_ENV'] || 'development')
require 'rack/contrib'
require 'newrelic_rpm'
unless ENV['RACK_ENV'] == 'production'
use Rack::ShowExceptions
end
ttl = ENV['DEFAULT_TTL'] ? ENV['DEFAULT_TTL'].to_i : 3600
use Rack::Cache,
:verbose => true,
:default_ttl => ttl,
:allow_reload => true,
:allow_revalidate => true,
:private_headers => [],
:metastore => "memcached://#{ENV['MEMCACHE_SERVERS'] || 'localhost:11211'}/meta",
:entitystore => "file:tmp/cache/rack/body"
use Rack::ResponseHeaders do |headers|
headers['Cache-Control'] = "public, max-age=#{ttl}"
end
use Rack::ETag
use Rack::CommonLogger
use Rack::Rewrite do
if feed_url = ENV['NESTA_FEED_URL']
r301 %r{/articles.xml(\?.*)?}, feed_url, :if => Proc.new { |rack_env|
ENV['RACK_ENV'] == 'production' && rack_env['HTTP_USER_AGENT'] !~ /FeedBurner/
}
end
end
require 'nesta/env'
Nesta::Env.root = ::File.expand_path('.', ::File.dirname(__FILE__))
require 'nesta/app'
run Nesta::App