View Source ExOciSdk.HTTPClient behaviour (ex_oci_sdk v0.2.0)

Defines the behaviour for HTTP clients in ExOciSdk.

This module specifies the contract that all HTTP client implementations must follow. It provides type specifications and a callback for making HTTP requests.

Summary

Callbacks

defines the dependencies necessary for the module

Types

body()

@type body() :: iodata()

error_reason()

@type error_reason() ::
  {:connect_failed, term()}
  | {:request_failed, term()}
  | {:receive_failed, term()}
  | :timeout
  | term()

headers()

@type headers() :: [{binary(), binary()}] | %{required(binary()) => binary()}

http_method()

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

options()

@type options() :: keyword()

response()

@type response() :: %{status_code: pos_integer(), headers: headers(), body: binary()}

url()

@type url() :: binary()

Callbacks

deps()

@callback deps() :: atom() | [atom()] | []

defines the dependencies necessary for the module

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

@callback request(
  method :: http_method(),
  url :: url(),
  body :: body(),
  headers :: headers(),
  options :: options()
) :: {:ok, response()} | {:error, error_reason()}

Makes an HTTP request.

Parameters

  • method - HTTP method as atom (e.g., :get, :post)
  • url - Full URL for the request
  • body - Request body as iodata
  • headers - List of request headers as tuples
  • options - Additional options for the request

Returns

  • {:ok, response} - Successful response with status, headers and body
  • {:error, reason} - Error occurred during request