forked from code-dot-org/code-dot-org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.ru
68 lines (54 loc) · 2.04 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require_relative '../deployment'
# Ensure all application secrets are loaded.
CDO.cdo_secrets&.required! unless rack_env?(:development) || CDO.unit_test
require File.expand_path('../router', __FILE__)
unless rack_env?(:development)
require 'cdo/app_server_metrics'
listener = CDO.pegasus_sock || "0.0.0.0:#{CDO.pegasus_port}"
use Cdo::AppServerMetrics,
listeners: [listener],
dimensions: {
Environment: CDO.rack_env,
Host: CDO.pegasus_hostname
}
end
require 'rack/csrf'
use Rack::Session::Cookie, secret: (CDO.sinatra_session_secret || 'dev_mode')
use Rack::Csrf, check_only: ['POST:/v2/poste/send-message']
require 'rack/ssl-enforcer'
use Rack::SslEnforcer,
# Add HSTS header to all HTTPS responses in all environments.
hsts: {expires: 31_536_000, subdomains: false},
# HTTPS redirect is handled at the HTTP-cache layer (CloudFront/Varnish).
# The only exception is in :development, where no HTTP-cache layer is present.
only_environments: 'development',
# Only HTTPS-redirect in development when `https_development` is true.
ignore: lambda {|request| !request.ssl? && !CDO.https_development}
require 'varnish_environment'
use VarnishEnvironment
unless CDO.chef_managed
# Only Chef-managed environments run an HTTP-cache service alongside the Rack app.
# For other environments (development / CI), run the HTTP cache from Rack middleware.
require 'cdo/rack/allowlist'
require File.expand_path('../../cookbooks/cdo-varnish/libraries/http_cache', __FILE__)
use Rack::Allowlist::Downstream,
HttpCache.config(rack_env)[:pegasus]
require 'rack/cache'
use Rack::Cache, ignore_headers: []
use Rack::Allowlist::Upstream,
HttpCache.config(rack_env)[:pegasus]
end
if CDO.image_optim
require 'cdo/rack/optimize'
use Rack::Optimize
end
# Disable Sinatra auto-initialization.
# Add Honeybadger::Rack::ErrorNotifier to Rack middleware directly.
use Honeybadger::Rack::ErrorNotifier
require 'files_api'
use FilesApi
require 'channels_api'
use ChannelsApi
require 'shared_resources'
use SharedResources
run Documents