Goth.HTTPClient behaviour (Goth v1.3.0-rc.3) View Source

Specification for a Goth HTTP client.

The client is configured as a {module, initial_state} tuple where the module implements this behaviour and initial_state is returned by the init/1 callback.

The init/1 callback gives an opportunity to perform some initialization tasks just once.

Link to this section Summary

Callbacks

Callback to initialize the given HTTP client.

Callback to make an HTTP request.

Link to this section Types

Specs

body() :: binary()

Specs

header() :: {binary(), binary()}

Specs

initial_state() :: map()

Specs

method() :: atom()

Specs

status() :: non_neg_integer()

Specs

url() :: binary()

Link to this section Callbacks

Specs

init(opts :: keyword()) :: initial_state()

Callback to initialize the given HTTP client.

The returned initial_state needs to be a map and will be given to request/6.

Link to this callback

request(method, url, list, body, opts, initial_state)

View Source

Specs

request(method(), url(), [header()], body(), opts :: keyword(), initial_state()) ::
  {:ok, %{status: status(), headers: [header()], body: body()}}
  | {:error, Exception.t()}

Callback to make an HTTP request.