aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-05-25 14:11:34 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-05-25 14:11:34 -0700
commit62c013d7b18d726d0ce10c3e7a1208d5e0e7fadf (patch)
treee9eb2252bb213db6e73e08eb04074ce056076e61 /actionpack/lib/action_dispatch
parentcff0d15e4b77d4a3f884f6f1c351a2d1660c8ccc (diff)
downloadrails-62c013d7b18d726d0ce10c3e7a1208d5e0e7fadf.tar.gz
rails-62c013d7b18d726d0ce10c3e7a1208d5e0e7fadf.tar.bz2
rails-62c013d7b18d726d0ce10c3e7a1208d5e0e7fadf.zip
pass a request to `matches?` so we can avoid creating excess requests
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb11
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb2
2 files changed, 6 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 9656109ed3..702d998447 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -35,19 +35,18 @@ module ActionDispatch
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
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 5839db87f9..7a565635f5 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -704,7 +704,7 @@ module ActionDispatch
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)