Loopback.HTTPRequest (Loopback v0.1.0)

Copy Markdown View Source

An intercepted HTTP request, as received by the fakes.

Fields

  • :method - the method in uppercase, like "GET".
  • :url - the full URL, including the query string.
  • :headers - a list of {name, value} tuples of strings, with names in lowercase. Defaults to [].
  • :body - the body as a binary, or nil when there's none. A body streamed by the client arrives whole. Defaults to nil.

Summary

Types

t()

An intercepted HTTP request.

Functions

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

Types

t()

@type t() :: %Loopback.HTTPRequest{
  body: binary() | nil,
  headers: [{String.t(), String.t()}],
  method: String.t(),
  url: String.t()
}

An intercepted HTTP request.

Functions

new(params)

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

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

Raises ArgumentError when :method or :url is missing.

Examples

Loopback.HTTPRequest.new(method: "GET", url: "https://api.example.com/users")