Posthog.HTTPClient behaviour (posthog v1.1.0)

View Source

Behaviour for HTTP client implementations.

This allows for easy swapping of HTTP clients and better testability.

Summary

Callbacks

Makes a POST request to the given URL with the specified body and headers.

Types

body()

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

headers()

@type headers() :: [{binary(), binary()}]

response()

@type response() :: %{status: pos_integer(), headers: headers(), body: map() | nil}

url()

@type url() :: binary()

Callbacks

post(url, body, headers, keyword)

@callback post(url(), body(), headers(), keyword()) ::
  {:ok, response()} | {:error, term()}

Makes a POST request to the given URL with the specified body and headers.

Returns {:ok, response} on success or {:error, reason} on failure.