Conduit v0.7.0 Conduit.Plug.Parse

Parses 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 text/plain.

This plug should be used in an incoming pipeline.

Examples

plug Conduit.Plug.Parse
plug Conduit.Plug.Parse, content_type: "application/json"

iex> import Conduit.Message
iex> message =
iex>   %Conduit.Message{}
iex>   |> put_body("{}")
iex>   |> Conduit.Plug.Parse.run(content_type: "application/json")
iex> message.body
%{}
iex> message.content_type
"application/json"

Summary

Functions

Formats the message body based on the content type

Callback implementation for Conduit.Plug.init/1

Callback implementation for Conduit.Plug.run/2

Functions

call(message, next, opts)

Formats the message body based on the content type.

init(opts)

Callback implementation for Conduit.Plug.init/1.

run(message, opts \\ [])

Callback implementation for Conduit.Plug.run/2.