Class: RoutesCoverage::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/routes_coverage/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



5
6
7
# File 'lib/routes_coverage/middleware.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#call(original_env) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/routes_coverage/middleware.rb', line 9

def call(original_env)
  # router changes env/request during recognition so need a copy:
  env = original_env.dup
  req = ::Rails.application.routes.request_class.new(env)
  RoutesCoverage._touch_request(req)

  # TODO: detect 404s? and maybe other route errors?
  @app.call(original_env)
end