Conduit v0.1.0 Conduit.Encoding behaviour
Encodes and decodes a message body based on the content encoding given.
Custom content encodings can be specified in your configuration.
config :conduit, Conduit.Encoding, [{"custom", MyApp.CustomEncoding}]
Note that any new content encodings specified in this way will require a recompile of Conduit.
$ mix deps.clean conduit --build
$ mix deps.get
Any custom content encodings should implement the Conduit.ContentType
behaviour. See Conduit.Encoding.GZip
for an example.
Summary
Functions
Decodes the message body with the specified content encoding
Encodes the message body with the specified content encoding
Functions
Decodes the message body with the specified content encoding.
Examples
iex> import Conduit.Message
iex> message =
iex> %Conduit.Message{}
iex> |> put_body(<<31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 171, 174, 5, 0, 67, 191, 166, 163, 2, 0, 0, 0>>)
iex> |> Conduit.Encoding.decode("gzip", [])
iex> message.body
"{}"
iex> get_meta(message, :content_encoding)
"gzip"
Encodes the message body with the specified content encoding.
Examples
iex> import Conduit.Message
iex> message =
iex> %Conduit.Message{}
iex> |> put_body("{}")
iex> |> Conduit.Encoding.encode("gzip", [])
iex> message.body
<<31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 171, 174, 5, 0, 67, 191, 166, 163, 2, 0, 0, 0>>
iex> get_meta(message, :content_encoding)
"gzip"