-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathconfig.ru
41 lines (37 loc) · 1.24 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
require 'oj'
require 'active_record'
require 'pg'
require 'logger'
require 'dalli'
require 'rack/cache'
require 'cuba'
require 'warden'
require './db'
require './app'
require './models/postal_code'
require './presenters/postal_codes'
require './authentication/token_strategy'
if ENV['VALIDATE_HEADER']
Warden::Strategies.add(:token, Authentication::TokenStrategy)
use Warden::Manager do |manager|
manager.default_strategies :token
manager.failure_app = lambda { |_e|
[401, { 'Content-Type' => 'application/json' },
[{ error: 'Not Authorized to use API. Check https://rapidapi.com/acrogenesis/api/mexico-zip-codes' }.to_json]]
}
end
end
if ENV['MEMCACHEDCLOUD_USERNAME']
client = Dalli::Client.new((ENV['MEMCACHEDCLOUD_SERVERS'] || 'memcached://localhost:11211').split(','),
username: ENV['MEMCACHEDCLOUD_USERNAME'],
password: ENV['MEMCACHEDCLOUD_PASSWORD'],
failover: true,
socket_timeout: 1.5,
socket_failure_delay: 0.2,
value_max_bytes: 10_485_760)
use Rack::Cache,
verbose: true,
metastore: client,
entitystore: client
end
run Cuba