Dowser.Client.HTTP.Adapter behaviour (Dowser.Client v0.1.1)

View Source

Behaviour implemented by every HTTP transport (:httpc, Req, :hackney).

Adapters are pure transport: given a fully-resolved request, they perform it and return a normalized Dowser.Client.Response (or an error). They do not encode/decode bodies — that is the JSON layer's job.

The url is expected to be a complete, absolute URL (endpoint + path + query string already joined). headers are string tuples. body is raw iodata or nil. opts are adapter-specific passthrough options; see each adapter's docs for the keys it understands.

Bundled implementations:

Summary

Types

body()

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

headers()

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

method()

@type method() :: :get | :post | :put | :patch | :delete | :head | :options

opts()

@type opts() :: keyword()

url()

@type url() :: String.t()

Callbacks

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

@callback request(method(), url(), headers(), body(), opts()) ::
  {:ok, Dowser.Client.Response.t()} | {:error, term()}