Skip to content

Commit

Permalink
improve custom body reader example (#1243)
Browse files Browse the repository at this point in the history
  • Loading branch information
thisistonydang authored Aug 29, 2024
1 parent 9037502 commit d8c1736
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/plug/parsers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,10 @@ defmodule Plug.Parsers do
defmodule CacheBodyReader do
def read_body(conn, opts) do
{:ok, body, conn} = Plug.Conn.read_body(conn, opts)
conn = update_in(conn.assigns[:raw_body], &[body | (&1 || [])])
{:ok, body, conn}
with {:ok, body, conn} <- Plug.Conn.read_body(conn, opts) do
conn = update_in(conn.assigns[:raw_body], &[body | &1 || []])
{:ok, body, conn}
end
end
end
Expand Down

0 comments on commit d8c1736

Please sign in to comment.