Closed tonydangblog closed 2 weeks ago
with
Change from:
{:ok, body, conn} = Plug.Conn.read_body(conn, opts)
To:
with {:ok, body, conn} <- Plug.Conn.read_body(conn, opts) do
This ensures that if Plug.Conn.read_body/2 fails, the function will return a meaningful error tuple instead of raising a MatchError. I saw this also suggested in this Dashbit article.
Plug.Conn.read_body/2
MatchError
conn = update_in(conn.assigns[:raw_body], &[body | (&1 || [])])
conn = update_in(conn.assigns[:raw_body], &[body | &1 || []])
This just removes the extra parens that the Elixir formatter would remove. :)
:green_heart: :blue_heart: :purple_heart: :yellow_heart: :heart:
Change example to use
with
Change from:
To:
This ensures that if
Plug.Conn.read_body/2
fails, the function will return a meaningful error tuple instead of raising aMatchError
. I saw this also suggested in this Dashbit article.Remove extra parentheses
Change from:
To:
This just removes the extra parens that the Elixir formatter would remove. :)