Conduit v0.1.1 Conduit.Plug.Format

Formats the message body based on the content type.

It uses in order of preference:

  1. The content type specified for the plug.
  2. The content type specified on the message.
  3. The default content type application/json.

This plug should be used in an outgoing pipeline.

plug Conduit.Plug.Format
plug Conduit.Plug.Format, content_type: "application/xml"

Summary

Functions

Formats the message body based on the content type

Callback implementation for Conduit.Plug.init/1

Functions

call(message, opts)

Formats the message body based on the content type.

Examples

iex> import Conduit.Message
iex> message =
iex>   %Conduit.Message{}
iex>   |> put_body(%{})
iex>   |> Conduit.Plug.Format.call([])
iex> message.body
"{}"
iex> get_meta(message, :content_type)
"application/json"
init(opts)

Callback implementation for Conduit.Plug.init/1.