class Trailer::Middleware::Rack

Public Class Methods

new(app) click to toggle source
# File lib/trailer/middleware/rack.rb, line 6
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/trailer/middleware/rack.rb, line 10
def call(env)
  if Trailer.enabled?
    RequestStore.store[:trailer] ||= Trailer.new
    RequestStore.store[:trailer].start
  end
  @app.call(env)
rescue Exception => e # rubocop:disable Lint/RescueException
  RequestStore.store[:trailer].add_exception(e) if Trailer.enabled?
  raise e
ensure
  RequestStore.store[:trailer].finish if Trailer.enabled?
end