PlugRequireHeader
An Elixir Plug for requiring and extracting a given header.
Summary↑
call(conn, options) | Extracts the required headers and assigns them to the connection struct |
init(options) | Initialises the plug given a keyword list |
Functions
Extracts the required headers and assigns them to the connection struct.
Arguments
conn
- the Plug.Conn connection struct
options
- a keyword list broken down into mandatory and optional options
Mandatory options
:headers
- a keyword list of connection key and header key pairs.
Each pair has the format [<connection_key>: <header_key>]
where
- the
<connection_key>
atom is the connection key to assign the value of the header. - the
<header_key>
binary is the header key to be required and extracted.
Optional options
:on_missing
- specifies how to handle a missing header. It can be one of
the following:
- a callback function with an arity of 2, specified as a tuple of
{module, function}
. The function will be called with theconn
struct and a tuple consisting of a connection assignment key and header key pair. Notice that the callback may be invoked once per required header.
Initialises the plug given a keyword list.