diff options
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 2c7ee7dad0..925e91f081 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -5,20 +5,20 @@ module ActionDispatch module Routing class Mapper class Constraints #:nodoc: - def self.new(app, constraints = []) + def self.new(app, constraints, request = Rack::Request) if constraints.any? - super(app, constraints) + super(app, constraints, request) else app end end - def initialize(app, constraints = []) - @app, @constraints = app, constraints + def initialize(app, constraints, request) + @app, @constraints, @request = app, constraints, request end def call(env) - req = Rack::Request.new(env) + req = @request.new(env) @constraints.each { |constraint| if constraint.respond_to?(:matches?) && !constraint.matches?(req) @@ -83,7 +83,8 @@ module ActionDispatch def app Constraints.new( to.respond_to?(:call) ? to : Routing::RouteSet::Dispatcher.new(:defaults => defaults), - blocks + blocks, + @set.request_class ) end @@ -242,7 +243,11 @@ module ActionDispatch lambda do |env| req = Request.new(env) - uri = URI.parse(path_proc.call(req.symbolized_path_parameters)) + + params = [req.symbolized_path_parameters] + params << req if path_proc.arity > 1 + + uri = URI.parse(path_proc.call(*params)) uri.scheme ||= req.scheme uri.host ||= req.host uri.port ||= req.port unless req.port == 80 |