This repository has been archived by the owner on Jun 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathconfig.ru
62 lines (49 loc) · 1.56 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
$LOAD_PATH.unshift File.join(__FILE__, '../lib')
require 'bandiera'
Bandiera.init(ENV['RACK_ENV'] || 'development')
if ENV['AIRBRAKE_API_KEY'] && ENV['AIRBRAKE_PROJECT_ID']
require 'socket'
require 'airbrake'
Airbrake.configure do |config|
config.project_key = ENV['AIRBRAKE_API_KEY']
config.project_id = ENV['AIRBRAKE_PROJECT_ID']
end
Airbrake.add_filter do |notice|
if notice[:errors].any? { |error| error[:type] == 'Sinatra::NotFound' }
notice.ignore!
end
end
end
if ENV['SENTRY_DSN']
require 'raven'
Raven.configure do |config|
config.dsn = ENV['SENTRY_DSN']
config.current_environment = ENV.fetch('RACK_ENV', 'development')
config.environments = ['production']
config.logger = Bandiera.logger
end
use Raven::Rack
end
if ENV['RACK_CORS_ORIGINS']
require 'rack/cors'
use Rack::Cors do
allow do
origins ENV['RACK_CORS_ORIGINS']
resource '/api/v2/*', headers: :any, methods: [:get, :options]
end
end
end
require 'prometheus/client/rack/collector'
require 'prometheus/client/rack/exporter'
use Prometheus::Client::Rack::Collector
use Prometheus::Client::Rack::Exporter
require 'macmillan/utils/statsd_middleware'
use Macmillan::Utils::StatsdMiddleware, client: Bandiera.statsd
require 'rack/not_so_common_logger'
use Rack::NotSoCommonLogger, Bandiera.logger
use Airbrake::Rack::Middleware if ENV['AIRBRAKE_API_KEY'] && ENV['AIRBRAKE_PROJECT_ID']
run Rack::URLMap.new(
'/' => Bandiera::GUI,
'/api/v1' => Bandiera::APIv1,
'/api/v2' => Bandiera::APIv2
)