PlugRequireHeader

An Elixir Plug for requiring and extracting a given header.

Source

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

call(conn, options)

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 and arity of 2, specified as a tuple of {module, function}. The function will be called with the conn struct and the missing header key. Notice that the callback may be invoked once per required header.
Source
init(options)

Initialises the plug given a keyword list.

Source