A response to an intercepted HTTP request, as returned by the fakes.
Fields
:status- the status code, like200.:headers- a list of{name, value}tuples of strings. Defaults to[].:body- the body as a binary. Defaults to"".
Summary
Functions
Builds a response with body encoded as JSON, and a
{"content-type", "application/json; charset=utf-8"} header prepended to headers.
Builds a response from a map or a keyword list of its fields.
Types
@type t() :: %Loopback.HTTPResponse{ body: binary(), headers: [{String.t(), String.t()}], status: non_neg_integer() }
A response to an intercepted HTTP request.
Functions
@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})
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)