9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/gorynich/head/rack_middleware.rb', line 9
def call(env)
Gorynich.instance.actualize
tenant, opts = Gorynich.switcher.analyze(env)
Gorynich.with(tenant, **opts) do
if Rails.logger.respond_to?(:tagged)
Rails.logger.tagged("Tenant(#{tenant})") { @app.call(env) }
else
@app.call(env)
end
end
rescue Gorynich::UriNotFound => e
Rails.logger.error(e.inspect)
[404, { 'Content-Type' => 'text/plain', 'charset' => 'UTF-8' }, [e.message]]
rescue Gorynich::HostNotFound => e
Rails.logger.error(e.inspect)
[404, { 'Content-Type' => 'text/plain', 'charset' => 'UTF-8' }, [e.message]]
rescue Gorynich::TenantNotFound => e
Rails.logger.error(e.inspect)
[404, { 'Content-Type' => 'text/plain', 'charset' => 'UTF-8' }, [e.message]]
end
|