Class: MetaRequest::Middlewares::AppRequestHandler
- Inherits:
-
Object
- Object
- MetaRequest::Middlewares::AppRequestHandler
- Defined in:
- lib/meta_request/middlewares/app_request_handler.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ AppRequestHandler
constructor
A new instance of AppRequestHandler.
Constructor Details
#initialize(app) ⇒ AppRequestHandler
Returns a new instance of AppRequestHandler.
8 9 10 |
# File 'lib/meta_request/middlewares/app_request_handler.rb', line 8 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/meta_request/middlewares/app_request_handler.rb', line 12 def call(env) app_request = AppRequest.new env['action_dispatch.request_id'] app_request.current! @app.call(env) rescue StandardError => e if defined?(ActionDispatch::ExceptionWrapper) wrapper = if ActionDispatch::ExceptionWrapper.method_defined? :env ActionDispatch::ExceptionWrapper.new(env, e) else ActionDispatch::ExceptionWrapper.new(env['action_dispatch.backtrace_cleaner'], e) end app_request.events.push(*Event.events_for_exception(wrapper)) else app_request.events.push(*Event.events_for_exception(e)) end raise ensure Storage.new(app_request.id).write(app_request.events.to_json) unless app_request.events.empty? end |