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

One media type of an `Accept` header, as PostgREST understands it.

`kind` is what PgRest can answer: `:json` (`application/json`), `:object`
(`application/vnd.pgrst.object[+json]`), `:array` (`application/vnd.pgrst.array[+json]`),
`:csv` (`text/csv`), `:plan` (`application/vnd.pgrst.plan[+json|+text]`), `:any` (`*/*`) or
`:other`. Matching is case-insensitive. `raw` is the type as the client wrote it with the `q`
parameter dropped (it is what a `PGRST107` lists). `nulls_stripped?` is the `nulls=stripped`
parameter, valid on `:array` and `:object` only. `plan` is set for `:plan`: its `format`, the
media type it is `for` (`application/json` when the client names none) and its `options`, in
PostgREST's order (`analyze`, `verbose`, `settings`, `buffers`, `wal`). A plan's `raw` is
PostgREST's canonical name for it, `application/vnd.pgrst.plan+<format>; for="<type>"` and
`; options=<a>|<b>` when there are any: what a `PGRST107` lists and the response echoes.

# `kind`

```elixir
@type kind() :: :json | :object | :array | :csv | :plan | :any | :other
```

# `plan`

```elixir
@type plan() :: %{format: :text | :json, for: t(), options: [plan_option()]}
```

# `plan_option`

```elixir
@type plan_option() :: :analyze | :verbose | :settings | :buffers | :wal
```

# `t`

```elixir
@type t() :: %PgRest.MediaType{
  kind: kind(),
  nulls_stripped?: boolean(),
  plan: plan() | nil,
  q: float(),
  raw: String.t()
}
```

# `any`

```elixir
@spec any() :: t()
```

The `*/*` any type, what a missing `Accept` header means.

# `body`

```elixir
@spec body(t()) :: t()
```

The media type a statement answers in: the type itself, `application/json` for `*/*`, and for
a plan the type it is `for`, so an explained statement is the one that would run for it.

# `content_type`

```elixir
@spec content_type(t()) :: String.t()
```

The `Content-Type` of a response in this media type. The stripped types name the parameter
as PostgREST does; an `:array` that is not stripped is plain JSON. Error bodies are always
`application/json`.

# `json`

```elixir
@spec json() :: t()
```

The default, `application/json`.

---

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