Class: Aikido::Zen::Middleware::SetContext
- Inherits:
-
Object
- Object
- Aikido::Zen::Middleware::SetContext
- Defined in:
- lib/aikido/zen/middleware/set_context.rb
Overview
Rack middleware that keeps the current context in a Thread/Fiber-local variable so that other parts of the agent/firewall can access it.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ SetContext
constructor
A new instance of SetContext.
Constructor Details
#initialize(app) ⇒ SetContext
Returns a new instance of SetContext.
13 14 15 |
# File 'lib/aikido/zen/middleware/set_context.rb', line 13 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/aikido/zen/middleware/set_context.rb', line 17 def call(env) context = Context.from_rack_env(env) Aikido::Zen.current_context = env[ENV_KEY] = context Aikido::Zen.track_request(context.request) @app.call(env) ensure Aikido::Zen.current_context = nil end |