Class: ZuoraConnect::Middleware::Hallway

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

Overview

Enables requests to be served from dynamic paths, determined by headers

Constant Summary collapse

UI_PATH =
'HTTP_ZUORA_UI_PATH'
LAYOUT_ID =
'HTTP_ZUORA_LAYOUT_FETCH_TEMPLATE_ID'

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Hallway

Returns a new instance of Hallway.



10
11
12
# File 'lib/zuora_connect/middleware/hallway.rb', line 10

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/zuora_connect/middleware/hallway.rb', line 14

def call(env)
  dynamic_path = env[UI_PATH].presence || layout_id(env)

  Thread.current[:isHallway] = dynamic_path

  if dynamic_path.present?
    env['SCRIPT_NAME'] = dynamic_path
    env['PATH_INFO'] = env['PATH_INFO'].sub(dynamic_path, '')
  end

  @app.call(env)
end