Class: Gorynich::Head::RackMiddleware
- Inherits:
-
Object
- Object
- Gorynich::Head::RackMiddleware
- Defined in:
- lib/gorynich/head/rack_middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ RackMiddleware
constructor
A new instance of RackMiddleware.
Constructor Details
#initialize(app) ⇒ RackMiddleware
Returns a new instance of RackMiddleware.
5 6 7 |
# File 'lib/gorynich/head/rack_middleware.rb', line 5 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
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.]] rescue Gorynich::HostNotFound => e Rails.logger.error(e.inspect) [404, { 'Content-Type' => 'text/plain', 'charset' => 'UTF-8' }, [e.]] rescue Gorynich::TenantNotFound => e Rails.logger.error(e.inspect) [404, { 'Content-Type' => 'text/plain', 'charset' => 'UTF-8' }, [e.]] end |