StarlingBank.HTTP.Transport behaviour (StarlingBank v1.0.0)

Copy Markdown View Source

Behaviour for the low-level HTTP transport used by StarlingBank.HTTP.Client.

The default implementation (StarlingBank.HTTP.Transport.Httpc) uses Erlang's built-in :httpc/:ssl, so StarlingBank has zero required runtime HTTP dependencies. Tests inject StarlingBank.HTTP.Transport.Fake (or any other module implementing this behaviour) via StarlingBank.Config{transport: ...}.

Summary

Types

body()

@type body() :: binary() | nil

headers()

@type headers() :: [{String.t(), String.t()}]

status()

@type status() :: pos_integer()

Callbacks

request(method, url, headers, body, opts)

@callback request(
  method :: atom(),
  url :: String.t(),
  headers :: headers(),
  body :: body(),
  opts :: keyword()
) :: {:ok, {status(), headers(), body()}} | {:error, term()}