rename project from SimpleshopTheme to Berrypod
All modules, configs, paths, and references updated. 836 tests pass, zero warnings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
22
lib/berrypod_web/plugs/cache_raw_body.ex
Normal file
22
lib/berrypod_web/plugs/cache_raw_body.ex
Normal file
@@ -0,0 +1,22 @@
|
||||
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
|
||||
Reference in New Issue
Block a user