View Source BunnyCDN.HTTPClient behaviour (bunny_cdn v0.1.0)

Http Client Behaviour specification.

The default http client uses Req underneath the hood. You can implement your own http client if your prefer a different http client. You'll need to set the :http_client configuration in BunnyCDN.Client:

client = %BunnyCDN.Client{http_client: {MyHTTPClient, []}}
BunnyCDN.get(client, "some/file.txt")

Link to this section Summary

Callbacks

Executes an HTTP request. Must return either {:ok, map} or {:error, reason}.

Link to this section Callbacks

Link to this callback

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

View Source
@callback request(
  method ::
    :get | :post | :head | :patch | :delete | :options | :put | String.t(),
  url :: String.t() | URI.t(),
  body :: iodata() | nil,
  headers ::
    [{header_name :: String.t(), header_value :: String.t()}] | [] | nil,
  options :: keyword()
) :: {:ok, binary(), term()} | {:error, term()}

Executes an HTTP request. Must return either {:ok, map} or {:error, reason}.