multiverse v2.0.0 Multiverse.Change behaviour

Provides behaviour for Multiverse API Changes.

Examples

defmodule ChangeAccountType do
  @behaviour Multiverse.Change

  def handle_request(%Plug.Conn{} = conn) do
    # Mutate your request here
    IO.inspect "GateName.mutate_request applied to request"
    conn
  end

  def handle_response(%Plug.Conn{} = conn) do
    # Mutate your response here
    IO.inspect "GateName.mutate_response applied to response"
    conn
  end
end

Link to this section Summary

Functions

Macros that can be used if you want to omit either handle_request/1 or handle_response/1 callback in your change module

Checks if change is active on connection or version schema

Callbacks

Defines a request mutator

Defines a response mutator

Link to this section Functions

Link to this macro __unsing__(opts) (macro)

Macros that can be used if you want to omit either handle_request/1 or handle_response/1 callback in your change module.

Link to this function active?(arg1, change)
active?(
  conn_or_version_schema :: Plug.Conn.t() | Multiverse.VersionSchema.t(),
  change :: module()
) :: boolean()

Checks if change is active on connection or version schema.

Link to this section Callbacks

Link to this callback handle_request(conn)
handle_request(conn :: Plug.Conn.t()) :: Plug.Conn.t()

Defines a request mutator.

This function will be called whenever Cowboy receives request.

Link to this callback handle_response(conn)
handle_response(conn :: Plug.Conn.t()) :: Plug.Conn.t()

Defines a response mutator.

This function will be called before Cowboy is dispatched response to a consumer.