multiverse v2.0.0 Multiverse.Adapter behaviour
This module provides behaviour for Multiverse adapters.
Link to this section Summary
Callbacks
Fetch default client version
Initializes adapter configuration at compile time
Resolve version by string value from request header
Comparator that is used to order and filter versions that should be applied to a connection
Link to this section Types
Link to this section Callbacks
fetch_default_version(conn :: Plug.Conn.t(), adapter_config :: config()) :: {:ok, version(), Plug.Conn.t()}
Fetch default client version.
This callback is used when version header is not set or empty. Additionally adapters may use it to fallback to default version in case of errors or when version header value is malformed.
Initializes adapter configuration at compile time.
This callback can be used to fetch Multiverse configuration from application environment, file or other places.
resolve_version_or_channel( conn :: Plug.Conn.t(), channel_or_version :: String.t(), adapter_config :: config() ) :: {:ok, version(), Plug.Conn.t()}
Resolve version by string value from request header.
This callback can be used to set named channels for API versions,
for eg. latest
header value could be resolved to current date and
edge
to the most recent defined version.
Also, it is responsible for casting string value to adapter-specific version type and handling possible errors.
You can terminate connection if you want to return error without further processing of the request.
Comparator that is used to order and filter versions that should be applied to a connection.
It should compare two arguments, and return true if the first argument precedes the second one or they are equal.