Class: Bulletin::Middleware
- Inherits:
-
Object
- Object
- Bulletin::Middleware
- Defined in:
- lib/bulletin/middleware.rb
Overview
Inserted after Bullet::Rack (i.e. inside it), so on the response unwind we run before Bullet’s own ‘ensure` nulls the thread-local collector. We read the already-deduped notifications, attach request context from the env (Bullet never populates notification.path), and hand a JSON-safe payload to the store. Persistence failures are swallowed — Bulletin must never break a host request.
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.
11 12 13 |
# File 'lib/bulletin/middleware.rb', line 11 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bulletin/middleware.rb', line 15 def call(env) status, headers, body = @app.call(env) begin persist(env) if recordable? rescue StandardError => e Bulletin.logger&.error("[Bulletin] failed to record warnings: #{e.class}: #{e.}") end [status, headers, body] end |