Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
meta_request / lib / meta_request / middlewares / app_request_handler.rb
Size: Mime:
require 'json'

module MetaRequest
  module Middlewares
    class AppRequestHandler
      def initialize(app)
        @app = app
      end

      def call(env)
        app_request = AppRequest.new env["action_dispatch.request_id"]
        app_request.current!
        @app.call(env)
      rescue Exception => exception
        if defined?(ActionDispatch::ExceptionWrapper)
          wrapper = ActionDispatch::ExceptionWrapper.new(env, exception)
          app_request.events.push(*Event.events_for_exception(wrapper))
        else
          app_request.events.push(*Event.events_for_exception(exception))
        end
        raise
      ensure
        Storage.new(app_request.id).write(app_request.events.to_json) unless app_request.events.empty?
      end
    end
  end
end