JustBash.HttpClient behaviour (JustBash v0.4.0)

View Source

Behaviour for HTTP clients used by curl command.

Implement this behaviour to provide custom HTTP handling for testing or to use a different HTTP library.

Summary

Types

error()

@type error() :: %{reason: atom() | String.t()}

method()

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

request()

@type request() :: %{
  method: method(),
  url: String.t(),
  headers: map(),
  body: String.t() | nil,
  timeout: non_neg_integer(),
  follow_redirects: boolean(),
  insecure: boolean()
}

response()

@type response() :: %{
  status: non_neg_integer(),
  headers: [{String.t(), String.t()}],
  body: String.t() | nil
}

Callbacks

request(request)

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