Routex.Extension behaviour (Routex v1.2.2)
View SourceSpecification for composable Routex extensions.
All callbacks are optional
See also: Routex Extensions
Summary
Callbacks
The configure/2
callback is called in the first stage with the options
provided to Routex
and the name of the Routex backend. It is expected to
return a new list of options.
The create_helpers/3
callback is called in the last stage with a list of
routes belonging to a Routex backend, the name of the Routex backend and
the current environment. It is expected to return Elixir AST.
The post_transform/1
callback is called in the third stage with a list of
routes belonging to a Routex backend. It is expected to return a list of
Phoenix.Router.Route structs almost identical to the input, only adding
Routex.Attrs
-for own usage- is allowed.
The transform/3
callback is called in the second stage with a list of
routes belonging to a Routex backend, the name of the configuration model
and the current environment. It is expected to return a list of
Phoenix.Router.Route structs with flattened Routex.Attrs
.
Callbacks
@callback configure(Routex.Types.opts(), Routex.Types.backend()) :: Routex.Types.opts()
The configure/2
callback is called in the first stage with the options
provided to Routex
and the name of the Routex backend. It is expected to
return a new list of options.
@callback create_helpers( Routex.Types.routes(), Routex.Types.backend(), Routex.Types.env() ) :: Routex.Types.ast()
The create_helpers/3
callback is called in the last stage with a list of
routes belonging to a Routex backend, the name of the Routex backend and
the current environment. It is expected to return Elixir AST.
The AST is included in MyAppWeb.Router.RoutexHelpers
.
@callback post_transform( Routex.Types.routes(), Routex.Types.backend(), Routex.Types.env() ) :: Routex.Types.routes()
The post_transform/1
callback is called in the third stage with a list of
routes belonging to a Routex backend. It is expected to return a list of
Phoenix.Router.Route structs almost identical to the input, only adding
Routex.Attrs
-for own usage- is allowed.
@callback transform(Routex.Types.routes(), Routex.Types.backend(), Routex.Types.env()) :: Routex.Types.routes()
The transform/3
callback is called in the second stage with a list of
routes belonging to a Routex backend, the name of the configuration model
and the current environment. It is expected to return a list of
Phoenix.Router.Route structs with flattened Routex.Attrs
.