apiac v1.0.0 APIac.Filter behaviour View Source
Specification for filter plug
A filter is a plug that allows or blocks a connection based in the connection information.
Link to this section Summary
Link to this section Types
Link to this section Callbacks
Link to this callback
filter(arg1, opts)
View Sourcefilter(Plug.Conn.t(), opts()) :: {:ok, Plug.Conn.t()} | {:error, Plug.Conn.t(), %APIac.Filter.Forbidden{ __exception__: term(), error_data: term(), filter: term(), reason: term() }}
Either allows or blocks the connection
Returns {:ok, Plug.Conn.t()}
if the connection is allowed. Returns
{:error, Plug.Conn.t(), %APIac.Filter.Forbidden{}}
otherwise.
The opts
parameter is the value returned by Plug.init/1
Link to this callback
send_error_response(arg1, %APIac.Filter.Forbidden{}, opts)
View Sourcesend_error_response( Plug.Conn.t(), %APIac.Filter.Forbidden{ __exception__: term(), error_data: term(), filter: term(), reason: term() }, opts() ) :: Plug.Conn.t()
Sets the HTTP error response and halts the plug
Specifically, it may set the headers, HTTP status code and HTTP body, depending on:
- The
Elixir.APIac.Filter
- The
opts[:error_response_verbosity]
function Specifics are to be documented in implementation plugs