Class: LogjamAgent::Middleware
- Inherits:
-
Object
- Object
- LogjamAgent::Middleware
- Defined in:
- lib/logjam_agent/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
3 4 5 6 |
# File 'lib/logjam_agent/middleware.rb', line 3 def initialize(app, ={}) @app = app @options = end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/logjam_agent/middleware.rb', line 8 def call(env) request = start_request(env) result = @app.call(env) result[1] ||= {} result rescue Exception result = [500, {'Content-Type' => 'text/html'}, ["<html><body><h1>500 Internal Server Error</h1>"]] ensure headers = result[1] headers["X-Logjam-Request-Id"] = request.id unless (caller_id = request.fields[:caller_id]).blank? headers["X-Logjam-Caller-Id"] = caller_id end finish_request(env) end |