errol v0.1.0 Errol.Middleware.Json View Source
Link to this section Summary
Functions
Parses json payload into an %Errol.Message{}
struct
Link to this section Functions
Link to this function
parse(message, queue)
View Source
parse(message :: Errol.Message.t(), queue :: String.t()) :: {:ok, Errol.Message.t()} | {:error, reason :: any()}
Parses json payload into an %Errol.Message{}
struct.
This is thought to be used in your wiring as:
pipe_before Errol.Middleware.Json.parse/1
This way the payload of every message consumed will be parsed before executing the consumer callback.
To use this you will need to install the jason hex.
iex> Errol.Middleware.Json.parse(%Errol.Message{payload: ~s({"userId": 1})}, "queue_name")
{:ok, %Errol.Message{meta: %{}, payload: %{"userId" => 1}}}