multiverse v2.0.0 Multiverse

This plug helps to manage multiple API versions based on request and response gateways. This is an awesome practice to hide your backward compatibility. It allows to have your code in a latest possible version, without duplicating controllers or models.

For more information see README.md.

Link to this section Summary

Functions

Callback implementation for Plug.call/2

Initializes Multiverse plug

Link to this section Types

Link to this type config()
config() :: %{
  adapter: module(),
  version_header: String.t(),
  gates: Multiverse.Adapter.gates(),
  adapter_config: Multiverse.Adapter.config()
}

Link to this section Functions

Link to this function call(conn, config)
call(conn :: Plug.Conn.t(), config :: config()) :: Plug.Conn.t()

Callback implementation for Plug.call/2.

Link to this function init(opts)
init(opts :: Keyword.t()) :: config()

Initializes Multiverse plug.

Raises at compile time when adapter or change is not loaded.

Available options:

  • :endpoint - endpoint which is used to fetch configuration from application environment;
  • :adapter - module which implements Multiverse.Adapter behaviour;
  • :version_header - header which is used to fetch consumer version;
  • :gates - list of gates (and changes) that are available for consumers.