Waffle.HTTPClient behaviour (waffle v2.0.0)

Copy Markdown View Source

Defines the behavior for http client.

Summary

Types

body()

@type body() :: binary()

error()

@type error() ::
  :timeout
  | {:unexpected_status, status()}
  | :response_body_limit_exceeded
  | :http_client

error_response()

@type error_response() :: %Waffle.HTTPClient.Error{
  error: error(),
  error_context: term(),
  request: term()
}

filename()

@type filename() :: String.t()

header()

@type header() :: {String.t(), String.t()}

headers()

@type headers() :: [header()]

option()

@type option() ::
  {:max_redirects, non_neg_integer() | nil}
  | {:max_retries, non_neg_integer()}
  | {:receive_timeout_ms, non_neg_integer()}
  | {:connect_timeout_ms, non_neg_integer()}
  | {:max_body_length_bytes, non_neg_integer() | nil}
  | {:backoff_factor_ms, non_neg_integer()}
  | {:backoff_max_ms, non_neg_integer()}

options()

@type options() :: [option()]

response()

@type response() :: %Waffle.HTTPClient.Response{
  body: body(),
  filename: filename() | nil
}

status()

@type status() :: 100..599

url()

@type url() :: String.t()

Callbacks

get(url, headers, options)

@callback get(url(), headers(), options()) ::
  {:ok, response()} | {:error, error_response()}