MillionSend.HTTP behaviour (MillionSend v0.3.0)

Copy Markdown View Source

Behaviour for the swappable HTTP layer. The default is MillionSend.HTTP.Req; tests inject a stub by building a client with http_client: set to a module implementing this behaviour.

Summary

Types

request()

@type request() :: %{
  method: :get | :post | :patch | :delete,
  url: String.t(),
  headers: [{String.t(), String.t()}],
  body: iodata() | nil
}

response()

@type response() :: %{status: non_neg_integer(), body: binary() | nil}

Callbacks

request(request)

@callback request(request()) :: {:ok, response()} | {:error, term()}