Plug.Parsers body-reader callback that stashes the raw request body
in conn.assigns.raw_body before handing it off to the parser.
Signature verification (HMAC over the raw bytes) can't run against a
parsed body — by the time Plug.Parsers decodes the JSON, the exact
byte sequence is gone. This reader captures the bytes first.
Wire it up in the host app's Plug pipeline:
plug Plug.Parsers,
parsers: [:json, :urlencoded],
body_reader: {SkillKit.Webhook.BodyReader, :read_body, []},
json_decoder: Jason
Summary
Functions
Reads the request body and appends the chunk to conn.assigns.raw_body.
Functions
@spec read_body(Plug.Conn.t(), Plug.opts()) :: {:ok, binary(), Plug.Conn.t()} | {:more, binary(), Plug.Conn.t()} | {:error, term()}
Reads the request body and appends the chunk to conn.assigns.raw_body.
Returns {:ok, body, conn} when the body has been fully read, or
{:more, partial, conn} if more bytes remain — matching the
Plug.Conn.read_body/2 contract that Plug.Parsers expects.