跳至內容 跳至搜尋

Action Dispatch Callbacks

提供在請求派送之前和之後執行的 callbacks。

方法
A
B
C
N
包含的模組

類別公開方法

after(*args, &block)

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

before(*args, &block)

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

new(app)

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

執行個體公開方法

call(env)

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