This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.ru
61 lines (48 loc) · 1.46 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
# frozen_string_literal: true
$LOAD_PATH.unshift File.join(__FILE__, '../lib')
require 'bandiera'
Bandiera.init
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|
notice.ignore! if notice[:errors].any? { |error| error[:type] == 'Sinatra::NotFound' }
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: %i[get options]
end
end
end
require 'rack'
require 'prometheus/middleware/collector'
require 'prometheus/middleware/exporter'
use Rack::Deflater
use Prometheus::Middleware::Collector
use Prometheus::Middleware::Exporter
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
)