Class: Appsignal::Rack::Events
- Defined in:
- lib/appsignal/rack/event_middleware.rb
Direct Known Subclasses
Defined Under Namespace
Classes: EventedBodyProxy
Instance Method Summary collapse
-
#call(env) ⇒ Object
The ‘call` method, exactly as implemented by Rack::Events, but redefined here so that it uses our EventedBodyProxy instead of the original Rack::Events::EventedBodyProxy.
Instance Method Details
#call(env) ⇒ Object
The ‘call` method, exactly as implemented by Rack::Events, but redefined here so that it uses our EventedBodyProxy instead of the original Rack::Events::EventedBodyProxy.
This fixes streaming bodies, but it also means that the ‘on_send` event on the handlers is never called.
See the original implementation at: github.com/rack/rack/blob/8d3d7857fcd9e5df057a6c22458bab35b3a19c12/lib/rack/events.rb#L111-L129
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/appsignal/rack/event_middleware.rb', line 58 def call(env) request = make_request env on_start request, nil begin status, headers, body = @app.call request.env response = make_response status, headers, body on_commit request, response rescue StandardError => e on_error request, response, e on_finish request, response raise end body = EventedBodyProxy.new(body, request, response, @handlers) do on_finish request, response end [response.status, response.headers, body] end |