Metal 文件下的内容
action
use
middleware & middleware_stack
controller_namedispatch
content_type
content_type=
location
location=
params
params=
status
status=
performed?
response_body=
controller_name
env
url_for最后更新于
action
use
middleware & middleware_stack
controller_namedispatch
content_type
content_type=
location
location=
params
params=
status
status=
performed?
response_body=
controller_name
env
url_for最后更新于
# Action Dispatch 转发过来的请求,要先经过层层的 middleware 处理,才能到达指定的 action.
def self.action(name, klass = ActionDispatch::Request)
if middleware_stack.any?
middleware_stack.build(name) do |env|
new.dispatch(name, klass.new(env))
end
else
lambda { |env| new.dispatch(name, klass.new(env)) }
end
endclass PostsController < ApplicationController
use AuthenticationMiddleware, except: [:index, :show]
endclass_attribute :middleware_stack
self.middleware_stack = ActionController::MiddlewareStack.new