Mojentic.HTTP behaviour (Mojentic v1.5.0)

Copy Markdown View Source

Behaviour for HTTP clients used by Mojentic gateways.

This behaviour abstracts the HTTP client, allowing different implementations for production and testing.

Summary

Types

headers()

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

response()

@type response() :: %{status_code: integer(), body: String.t(), headers: headers()}

Callbacks

get(url, headers, opts)

@callback get(url :: String.t(), headers :: headers(), opts :: keyword()) ::
  {:ok, response()} | {:error, term()}

post(url, body, headers, opts)

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

post_stream(url, body, headers, opts)

@callback post_stream(
  url :: String.t(),
  body :: String.t(),
  headers :: headers(),
  opts :: keyword()
) :: {:ok, Enumerable.t()} | {:error, term()}