Class: Errsight::Middleware
- Inherits:
-
Object
- Object
- Errsight::Middleware
- Defined in:
- lib/errsight/middleware.rb
Overview
Rack middleware that stores the request_id on the current thread so the Errsight::Logger can tag every log line with it.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
5 6 7 |
# File 'lib/errsight/middleware.rb', line 5 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/errsight/middleware.rb', line 9 def call(env) Thread.current[:errsight_request_id] = env["action_dispatch.request_id"] || env["HTTP_X_REQUEST_ID"] @app.call(env) ensure Thread.current[:errsight_request_id] = nil end |