Conduit v0.12.10 Conduit.Plug.Decode View Source
Decodes the message body based on the content encoding.
It uses in order of preference:
- The content encoding specified for the plug.
- The content encoding specified on the message.
- The default content encoding
identity
.
The location of the content encoding can be changed from content_encoding
to a header with the :header
option. This is useful for having multiple
encodings, like a transfer encoding.
This plug should be used in an incoming pipeline. Generally before
a Conduit.Plug.Parse
plug.
Examples
plug Conduit.Plug.Decode
plug Conduit.Plug.Decode, content_encoding: "gzip"
plug Conduit.Plug.Decode, header: "transfer_encoding"
iex> import Conduit.Message
iex> message =
iex> %Conduit.Message{}
iex> |> put_body("{}")
iex> |> Conduit.Plug.Decode.run
iex> message.body
"{}"
iex> message.content_encoding
"identity"
iex> import Conduit.Message
iex> message =
iex> %Conduit.Message{}
iex> |> put_body("{}")
iex> |> Conduit.Plug.Decode.run(header: "transfer_encoding")
iex> message.body
"{}"
iex> get_header(message, "transfer_encoding")
"identity"
Link to this section Summary
Functions
Formats the message body based on the content encoding
Callback implementation for Conduit.Plug.init/1
Callback implementation for Conduit.Plug.run/2
Link to this section Functions
Formats the message body based on the content encoding.
Callback implementation for Conduit.Plug.init/1
.
Callback implementation for Conduit.Plug.run/2
.