Skip to content
Browse files

use the request object since we have it

stop hardcoding hash keys and use the accessors provided on the request
object.
  • Loading branch information...
1 parent 2fdddce commit a6e94547e84ae692a084a95f2c3ba02d513edf3e @tenderlove tenderlove committed May 23, 2014
View
17 actionpack/lib/action_dispatch/journey/router.rb
@@ -55,26 +55,27 @@ def initialize(routes, options)
end
def call(env)
- env['PATH_INFO'] = Utils.normalize_path(env['PATH_INFO'])
-
req = request_class.new(env)
+ req.path_info = Utils.normalize_path(req.path_info)
+
find_routes(env, req).each do |match, parameters, route|
- set_params = req.path_parameters
- script_name, path_info = env.values_at('SCRIPT_NAME', 'PATH_INFO')
+ set_params = req.path_parameters
+ path_info = req.path_info
+ script_name = req.script_name
unless route.path.anchored
- env['SCRIPT_NAME'] = (script_name.to_s + match.to_s).chomp('/')
- env['PATH_INFO'] = match.post_match
+ req.script_name = (script_name.to_s + match.to_s).chomp('/')
+ req.path_info = match.post_match
end
req.path_parameters = set_params.merge parameters
status, headers, body = route.app.call(env)
if 'pass' == headers['X-Cascade']
- env['SCRIPT_NAME'] = script_name
- env['PATH_INFO'] = path_info
+ req.script_name = script_name
+ req.path_info = path_info
req.path_parameters = set_params
next
end
View
8 actionpack/test/dispatch/routing_test.rb
@@ -3368,15 +3368,13 @@ def expected_redirect_body(url)
class TestAltApp < ActionDispatch::IntegrationTest
class AltRequest
- attr_accessor :path_parameters
+ attr_accessor :path_parameters, :path_info, :script_name
def initialize(env)
@path_parameters = {}
@env = env
- end
-
- def path_info
- "/"
+ @path_info = "/"
+ @script_name = ""
end
def request_method
View
4 actionpack/test/journey/router_test.rb
@@ -12,7 +12,9 @@ class StubDispatcher < Routing::RouteSet::Dispatcher; end
def setup
@app = StubDispatcher.new
@routes = Routes.new
- @router = Router.new(@routes, {})
+ @router = Router.new(@routes, {
+ :request_class => ActionDispatch::Request
+ })
@formatter = Formatter.new(@routes)
end

0 comments on commit a6e9454

Please sign in to comment.
Something went wrong with that request. Please try again.