Class: MissionControl::Web::RequestFilterMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/mission_control/web/request_filter_middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RequestFilterMiddleware

Returns a new instance of RequestFilterMiddleware.



3
4
5
# File 'lib/mission_control/web/request_filter_middleware.rb', line 3

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
# File 'lib/mission_control/web/request_filter_middleware.rb', line 7

def call(env)
  filter(env) || @app.call(env)
end

#filter(env) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/mission_control/web/request_filter_middleware.rb', line 11

def filter(env)
  return unless MissionControl::Web.configuration.middleware_enabled?

  request = ActionDispatch::Request.new(env)

  if action = request.mission_control.action
    errors_controller.action(action).call(request.env)
  end
end