View Source HTTPSpec.Response (http_spec v3.0.0)

A struct for describing HTTP responses.

Summary

Functions

Creates a response from given options.

Bang version of new/1.

Types

@type body() :: iodata() | nil
@type status() :: non_neg_integer()
@type t() :: %HTTPSpec.Response{
  body: body(),
  headers: HTTPSpec.Header.headers(),
  status: status(),
  trailers: HTTPSpec.Trailer.trailers()
}

Functions

@spec new(keyword() | map()) :: {:ok, t()} | {:error, HTTPSpec.ArgumentError.t()}

Creates a response from given options.

The options can be provided as a keyword list or a map.

Examples

HTTPSpec.Response.new(%{
  status: 200,
  headers: [
    {"content-type", "text/html"}
  ],
  body: "<html>...</html>"
})
@spec new!(keyword() | map()) :: t()

Bang version of new/1.