Conduit v0.12.10 Conduit.ContentType behaviour View Source
Formats and parses a message body based on the content type given.
Custom content types can be specified in your configuration.
config :conduit, Conduit.ContentType, [{"application/x-custom", MyApp.CustomContentType}]
Note that any new content types specified in this way will require a recompile of Conduit.
$ mix deps.clean conduit --build
$ mix deps.get
Any custom content types should implement the Conduit.ContentType
behaviour. See Conduit.ContentType.JSON
for an example.
Link to this section Summary
Functions
Formats the message body with the specified content type
Parses the message body with the specified content type
Link to this section Functions
Link to this function
format(message, type, opts)
View Source
format(Conduit.Message.t(), String.t(), Keyword.t()) :: Conduit.Message.t()
Formats the message body with the specified content type.
Examples
iex> import Conduit.Message
iex> message =
iex> %Conduit.Message{}
iex> |> put_body(%{})
iex> |> Conduit.ContentType.format("application/json", [])
iex> message.body
"{}"
Link to this function
parse(message, type, opts)
View Source
parse(Conduit.Message.t(), String.t(), Keyword.t()) :: Conduit.Message.t()
Parses the message body with the specified content type.
Examples
iex> import Conduit.Message
iex> message =
iex> %Conduit.Message{}
iex> |> put_body("{}")
iex> |> Conduit.ContentType.parse("application/json", [])
iex> message.body
%{}
Link to this section Callbacks
Link to this callback
format(arg0, arg1)
View Source
format(Conduit.Message.t(), Keyword.t()) :: Conduit.Message.t()
Link to this callback
parse(arg0, arg1)
View Source
parse(Conduit.Message.t(), Keyword.t()) :: Conduit.Message.t()