# `Loopback.HTTPResponse`
[🔗](https://github.com/stefanchrobot/loopback/blob/v0.1.0/lib/loopback/http_response.ex#L1)

A response to an intercepted HTTP request, as returned by the fakes.

## Fields

  * `:status` - the status code, like `200`.
  * `:headers` - a list of `{name, value}` tuples of strings. Defaults to `[]`.
  * `:body` - the body as a binary. Defaults to `""`.

# `t`

```elixir
@type t() :: %Loopback.HTTPResponse{
  body: binary(),
  headers: [{String.t(), String.t()}],
  status: non_neg_integer()
}
```

A response to an intercepted HTTP request.

# `json`

```elixir
@spec json(non_neg_integer(), term(), [{String.t(), String.t()}]) :: t()
```

Builds a response with `body` encoded as JSON, and a
`{"content-type", "application/json; charset=utf-8"}` header prepended to `headers`.

## Examples

    Loopback.HTTPResponse.json(200, %{"id" => 123})

# `new`

```elixir
@spec new(map() | keyword()) :: t()
```

Builds a response from a map or a keyword list of its fields.

Raises `ArgumentError` when `:status` is missing.

## Examples

    Loopback.HTTPResponse.new(status: 204)

---

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