Class: Middleware::AppTypeDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/middleware/app_type_detector.rb

Overview

Rack middleware that resolves the Heatwave::AppType for the
current request from the Host header and stashes it on
Heatwave::AppType.current for the duration of the request. Must
be installed near the top of the middleware stack so downstream
middleware/controllers can branch on the value.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ AppTypeDetector

Returns a new instance of AppTypeDetector.



19
20
21
# File 'lib/middleware/app_type_detector.rb', line 19

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



23
24
25
26
27
28
# File 'lib/middleware/app_type_detector.rb', line 23

def call(env)
  # Detect and store app type for this request
  Heatwave::AppType.current = Heatwave::AppType.from_request(env)

  @app.call(env)
end