Class: Rack::MsHeaderTrail

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/ms_header_trail.rb

Overview

Public: Rack middleware that stores the collection data from header in a thread local variable.

Examples

use Rack::MsHeaderTrail

Constant Summary collapse

REQUEST_HEADER_PREFIX =
"HTTP_X_"
RESPONSE_HEADER_PREFIX =
"X-"

Instance Method Summary collapse

Constructor Details

#initialize(app, options = nil) ⇒ MsHeaderTrail

Returns a new instance of MsHeaderTrail.



15
16
17
18
# File 'lib/rack/ms_header_trail.rb', line 15

def initialize(app, options = nil)
  @app = app
  @options = options
end

Instance Method Details

#call(env) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/rack/ms_header_trail.rb', line 20

def call(env)
  ::MsHeaderTrail.with(retrive_from_header(env)) do
    status, headers, body = @app.call(env)

    into_headers(headers) if ::MsHeaderTrail.configuration.rack_header_response

    [status, headers, body]
  end
end