Dispatcher
将 HTTP 请求向具体的 Controller#action 转移。
继承于 Routing::Endpoint
module ActionDispatch
module Routing
class RouteSet
def dispatcher(defaults)
Routing::RouteSet::Dispatcher.new(defaults)
end
end
end
end实例方法:
dispatcher?
serve
prepare_params!
controller私有方法:
最重要的方法是 dispatch,将战场切换到 Controller#action
每一条路由规则,对应着一个 Dispatcher 实例。
每一个路由规则转换着 draw 对应一个 Dispatcher 实例。
用最简单的 get 方法举例:
生成实例:
app 如果条件匹配,将要执行的 Rack application.
conditions 匹配条件。执行此 Rack application 要匹配什么条件。
defaults 默认参数。
requirements 对应方法里的 :constraints 参数。
as 对应方法里的 :as 参数。
最后更新于
这有帮助吗?