All modules, configs, paths, and references updated. 836 tests pass, zero warnings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
23 lines
631 B
Elixir
23 lines
631 B
Elixir
defmodule BerrypodWeb.Plugs.CacheRawBody do
|
|
@moduledoc """
|
|
Custom body reader that caches the raw request body for webhook signature verification.
|
|
Used with Plug.Parsers :body_reader option.
|
|
"""
|
|
|
|
def read_body(conn, opts) do
|
|
case Plug.Conn.read_body(conn, opts) do
|
|
{:ok, body, conn} ->
|
|
conn = Plug.Conn.assign(conn, :raw_body, body)
|
|
{:ok, body, conn}
|
|
|
|
{:more, body, conn} ->
|
|
existing = conn.assigns[:raw_body] || ""
|
|
conn = Plug.Conn.assign(conn, :raw_body, existing <> body)
|
|
{:more, body, conn}
|
|
|
|
{:error, reason} ->
|
|
{:error, reason}
|
|
end
|
|
end
|
|
end
|