我需要像这样添加一个中间件:
class AfterFailure < Grape::Middleware::Base
def call!(env)
@env = env
before
error = catch (:error) do
@app_response = @app.call(@env)
return after || @app_response
end
after_failure(error) || throw(:error, error) end
def after_failure(error)
puts "After Failure"
nil end
end
但我不知道如何将其添加到api中,我该怎么做?
答案 0 :(得分:0)
知道了。检查源代码,找到:
use AfterFailure