Ich brauche zwei Pipelines in meiner web/router.ex
Datei wie folgt zu definieren:Wie kann eine Router-Pipeline-Definition in einer anderen Pipeline-Definition in Phoenix Framework wiederverwendet werden?
pipeline :api do
plug :accepts, ["json"]
plug :fetch_session
plug MyApp.Plugs.ValidatePayload
end
pipeline :restricted_api do
plug :accepts, ["json"]
plug :fetch_session
plug MyApp.Plugs.ValidatePayload
plug MyApp.Plugs.EnsureAuthenticated
plug MyApp.Plugs.EnsureAuthorized
end
Man kann deutlich sehen, dass Schritte von der :api
Pipeline in der Pipeline :restricted_api
dupliziert werden.
Gibt es eine Möglichkeit, die Pipeline :api
in der Pipeline :restricted_api
wiederzuverwenden?
Ich denke an etwas ähnlichen Erbe:
pipeline :api do
plug :accepts, ["json"]
plug :fetch_session
plug MyApp.Plugs.ValidatePayload
end
pipeline :restricted_api do
extend :api
plug MyApp.Plugs.EnsureAuthenticated
plug MyApp.Plugs.EnsureAuthorized
end