Conduit v0.1.0 Conduit.Plug.Builder
A module that can be used to build pipelines of plugs.
Examples
iex> import Conduit.Message
iex>
iex> defmodule MyPipeline do
iex> use Conduit.Plug.Builder
iex>
iex> plug Conduit.Plug.Format
iex> plug Conduit.Plug.Encode
iex> end
iex>
iex> message =
iex> %Conduit.Message{}
iex> |> put_body(%{})
iex> |> MyPipeline.call([])
iex> message.body
"{}"
iex> get_meta(message, :content_type)
"application/json"
iex> get_meta(message, :content_encoding)
"identity"
Summary
Functions
Compiles a plug pipeline
Macros
A macro that stores a new plug. opts
will be passed unchanged to the new
plug
Types
Functions
Compiles a plug pipeline.
Each element of the plug pipeline (according to the type signature of this function) has the form:
{plug_name, options, guards}
Note that this function expects a reversed pipeline (with the last plug that has to be called coming first in the pipeline).
The function returns a tuple with the first element being a quoted reference to the connection and the second element being the compiled quoted pipeline.
Examples
Conduit.Plug.Builder.compile(env, [
{Conduit.Plug.Format, [], true}, # no guards, as added by the Plug.Builder.plug/2 macro
{Conduit.Plug.Encode, [], quote(do: a when is_binary(a))}
], [])
Macros
A macro that stores a new plug. opts
will be passed unchanged to the new
plug.
This macro doesn’t add any guards when adding the new plug to the pipeline;
for more information about adding plugs with guards see compile/1
.
Examples
plug Conduit.Plug.Format # plug module
plug :put_meta, content_encoding: "gzip" # plug function