View Source ChannelHandler.Plug behaviour (channel_handler v0.6.2)

A ChannelHandler.Plug, is a function or module that takes the connection socket, the payload and the current handler bindings, and either returns a modified version of each, or directly replies to the client, halting further processing.

The plug can either be a module implementing the ChannelHandler.Plug behaviour, or an function of arity 4

examples

Examples

def call(socket, _payload, _bindings, _opts) do
  case authenticated?(socket) do
    {:cont, socket, payload, bindings}
  else
    {:reply, {:error, "Not authenticated"}, socket}
  end
end

Link to this section Summary

Link to this section Callbacks

Link to this callback

call(t, payload, bindings, t)

View Source
@callback call(Phoenix.Socket.t(), payload :: term(), bindings :: map(), Keyword.t()) ::
  {:cont, Phoenix.Socket.t(), term(), map()}
  | {:reply, term(), Phoenix.Socket.t()}
  | {:noreply, Phoenix.Socket.t()}