A Plug.Parsers body reader that keeps the raw request body, which is
needed to verify webhook signatures after the JSON has been parsed.
plug Plug.Parsers,
parsers: [:json],
pass: ["*/*"],
body_reader: {KapsoEx.Webhook.CacheBodyReader, :read_body, []},
json_decoder: JasonThen read it back with raw_body/1. Only available when :plug is a
dependency of your application.
Summary
Functions
Returns the raw body cached by read_body/2, or nil when it was not read.
Reads the body like Plug.Conn.read_body/2 and stores a copy in conn.private.
Functions
@spec raw_body(Plug.Conn.t()) :: binary() | nil
Returns the raw body cached by read_body/2, or nil when it was not read.
@spec read_body(Plug.Conn.t(), keyword()) :: {:ok, binary(), Plug.Conn.t()} | {:more, binary(), Plug.Conn.t()} | {:error, term()}
Reads the body like Plug.Conn.read_body/2 and stores a copy in conn.private.