Class: Houser::Middleware
- Inherits:
-
Object
- Object
- Houser::Middleware
- Defined in:
- lib/houser/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
5 6 7 8 9 10 |
# File 'lib/houser/middleware.rb', line 5 def initialize(app, ={}) = [:class_name] = Object.const_get([:class_name]) [:tld_length] ||= 1 @app = app end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/houser/middleware.rb', line 12 def call(env) domain_parts = env['HTTP_HOST'].split('.') if domain_parts.length > 1 + [:tld_length] subdomain = domain_parts[0] find_tenant(env, subdomain) end @app.call(env) end |