Skip to content

Instantly share code, notes, and snippets.

@colinrymer
Created October 15, 2015 14:54
Show Gist options
  • Save colinrymer/dbfcf39c9a6540829d08 to your computer and use it in GitHub Desktop.
Save colinrymer/dbfcf39c9a6540829d08 to your computer and use it in GitHub Desktop.
raw request body plug
defmodule Foo.Plugs.CopyReqBody do
import Plug.Conn
def init(mount: "/" <> mount), do: mount
def call(conn = %Plug.Conn{path_info: [mount | _rest]}, mount) do
put_private(conn, :req_body, read_body(conn))
end
def call(conn, _), do: conn
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment