pass a request to matches?
so we can avoid creating excess requests
This commit is contained in:
parent
cff0d15e4b
commit
62c013d7b1
@ -35,19 +35,18 @@ def initialize(app, constraints, request, dispatcher_p)
|
||||
|
||||
def dispatcher?; @dispatcher; end
|
||||
|
||||
def matches?(env)
|
||||
req = @request.new(env)
|
||||
|
||||
def matches?(req)
|
||||
@constraints.all? do |constraint|
|
||||
(constraint.respond_to?(:matches?) && constraint.matches?(req)) ||
|
||||
(constraint.respond_to?(:call) && constraint.call(*constraint_args(constraint, req)))
|
||||
end
|
||||
ensure
|
||||
req.reset_parameters
|
||||
end
|
||||
|
||||
def call(env)
|
||||
matches?(env) ? @app.call(env) : [ 404, {'X-Cascade' => 'pass'}, [] ]
|
||||
req = @request.new(env)
|
||||
matches?(req) ? @app.call(env) : [ 404, {'X-Cascade' => 'pass'}, [] ]
|
||||
ensure
|
||||
req.reset_parameters
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -704,7 +704,7 @@ def recognize_path(path, environment = {})
|
||||
old_params = req.path_parameters
|
||||
req.path_parameters = old_params.merge params
|
||||
app = route.app
|
||||
if app.matches?(env) && app.dispatcher?
|
||||
if app.matches?(req) && app.dispatcher?
|
||||
dispatcher = app.app
|
||||
|
||||
if dispatcher.controller(params, false)
|
||||
|
Loading…
Reference in New Issue
Block a user