我有一个看起来像这样的自定义插件:
defmodule Db.Auth.GuardianPipeline do
use Guardian.Plug.Pipeline,
otp_app: :db,
module: Db.Auth.Guardian
plug Guardian.Plug.VerifySession, claims: %{"typ" => "access"}
plug Guardian.Plug.VerifyHeader, claims: %{"typ" => "access"}
plug Guardian.Plug.LoadResource, allow_blank: true
plug Guardian.Plug.VerifySession, claims: %{"typ" => "access"}, key: :impersonated_user
plug Guardian.Plug.VerifyHeader, claims: %{"typ" => "access"}, key: :impersonated_user
plug Guardian.Plug.LoadResource, allow_blank: true, key: :impersonated_user
end
但是,我需要能够传入错误处理程序。我目前这样做:
pipeline :authenticate do
plug(Guardian.Plug.Pipeline, error_handler: Web.Auth.ErrorHandler)
plug(Db.Auth.GuardianPipeline)
end
我宁愿做这样的事情:
pipeline :authenticate do
plug(Db.Auth.GuardianPipeline, error_handler: Web.Auth.ErrorHandler)
end
并像这样或等效地把它传递到我的插件中:
defmodule Db.Auth.GuardianPipeline do
use Guardian.Plug.Pipeline,
otp_app: :db,
module: Db.Auth.Guardian,
error_handler: args["error_handler"],
plug Guardian.Plug.VerifySession, claims: %{"typ" => "access"}
plug Guardian.Plug.VerifyHeader, claims: %{"typ" => "access"}
plug Guardian.Plug.LoadResource, allow_blank: true
plug Guardian.Plug.VerifySession, claims: %{"typ" => "access"}, key: :impersonated_user
plug Guardian.Plug.VerifyHeader, claims: %{"typ" => "access"}, key: :impersonated_user
plug Guardian.Plug.LoadResource, allow_blank: true, key: :impersonated_user
end
如何将 args 从我的自定义插件传递到其内部调用的插件?