跳至内容 跳至搜索

Action Dispatch Callbacks

提供在分派请求之前和之后执行的回调。

方法
A
B
C
N
包含的模块

类公共方法

after(*args, &block)

# File actionpack/lib/action_dispatch/middleware/callbacks.rb, line 19
def after(*args, &block)
  set_callback(:call, :after, *args, &block)
end

before(*args, &block)

# File actionpack/lib/action_dispatch/middleware/callbacks.rb, line 15
def before(*args, &block)
  set_callback(:call, :before, *args, &block)
end

new(app)

# File actionpack/lib/action_dispatch/middleware/callbacks.rb, line 24
def initialize(app)
  @app = app
end

实例公共方法

call(env)

# File actionpack/lib/action_dispatch/middleware/callbacks.rb, line 28
def call(env)
  error = nil
  result = run_callbacks :call do
    @app.call(env)
  rescue => error
  end
  raise error if error
  result
end