# `PgRest.BodyReader`
[🔗](https://github.com/agoodway/pgrest/blob/v0.2.0/lib/pg_rest/body_reader.ex#L1)

A `Plug.Parsers` body reader that keeps the raw request body.

    plug Plug.Parsers,
      parsers: [:json],
      json_decoder: Jason,
      body_reader: {PgRest.BodyReader, :read_body, []}

The bytes accumulate in `conn.private[:pgrest_raw_body]`. `PgRest.Request`
uses them when present, which lets writes pass the original JSON to Postgres
instead of re-encoding the decoded payload.

# `read_body`

```elixir
@spec read_body(Plug.Conn.t(), keyword()) ::
  {:ok, binary(), Plug.Conn.t()}
  | {:more, binary(), Plug.Conn.t()}
  | {:error, term()}
```

Delegates to `Plug.Conn.read_body/2`, caching every chunk read.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
