Conduit v0.12.10 Conduit.Encoding behaviour View Source
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.
Link to this section Summary
Functions
Decodes the message body with the specified content encoding
Encodes the message body with the specified content encoding
Link to this section Functions
Link to this function
decode(message, encoding, opts)
View Source
decode(Conduit.Message.t(), String.t(), Keyword.t()) :: Conduit.Message.t()
Decodes the message body with the specified content encoding.
Examples
iex> import Conduit.Message
iex> body = <<31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 171, 174, 5, 0, 67, 191, 166, 163, 2, 0, 0, 0>>
iex> message =
iex> %Conduit.Message{}
iex> |> put_body(body)
iex> |> Conduit.Encoding.decode("gzip", [])
iex> message.body
"{}"
Link to this function
encode(message, encoding, opts)
View Source
encode(Conduit.Message.t(), String.t(), Keyword.t()) :: Conduit.Message.t()
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> :zlib.gunzip(message.body)
"{}"
Link to this section Callbacks
Link to this callback
decode(arg0, arg1)
View Source
decode(Conduit.Message.t(), Keyword.t()) :: Conduit.Message.t()
Link to this callback
encode(arg0, arg1)
View Source
encode(Conduit.Message.t(), Keyword.t()) :: Conduit.Message.t()