提交 229c9ed8 编写于 作者: A Aaron Patterson

Always construct route objects with Constraint objects

上级 98c7fe87
......@@ -14,10 +14,10 @@ def constraints
def rack_app(app = self.app)
@rack_app ||= begin
app = app.app
class_name = app.class.name.to_s
if class_name == "ActionDispatch::Routing::Mapper::Constraints"
app.app
elsif ActionDispatch::Routing::Redirect === app || class_name !~ /^ActionDispatch::Routing/
if ActionDispatch::Routing::Redirect === app || class_name !~ /^ActionDispatch::Routing/
app
end
end
......
......@@ -216,10 +216,12 @@ def normalize_conditions!
end
def app
endpoint = to.respond_to?(:call) ? to : dispatcher
if blocks.any?
Constraints.new(endpoint, blocks, @set.request_class)
else
endpoint
Constraints.new(endpoint, blocks, @set.request_class)
end
end
......@@ -306,10 +308,6 @@ def strexp
Journey::Router::Strexp.compile(path, requirements, SEPARATORS)
end
def endpoint
to.respond_to?(:call) ? to : dispatcher
end
def dispatcher
Routing::RouteSet::Dispatcher.new(defaults)
end
......
......@@ -704,7 +704,7 @@ def recognize_path(path, environment = {})
old_params = req.path_parameters
req.path_parameters = old_params.merge params
dispatcher = route.app
if dispatcher.is_a?(Mapper::Constraints) && dispatcher.matches?(env)
if dispatcher.matches?(env)
dispatcher = dispatcher.app
end
......
......@@ -3389,6 +3389,9 @@ def ip
def x_header
@env["HTTP_X_HEADER"] || ""
end
def reset_parameters
end
end
class XHeader
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册