提交 62c013d7 编写于 作者: A Aaron Patterson

pass a request to `matches?` so we can avoid creating excess requests

上级 cff0d15e
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册