Exosphere.ATProto.HTTP.Behaviour behaviour (Exosphere v0.2.0)

Copy Markdown View Source

Behaviour for HTTP clients.

Allows mocking HTTP requests in tests.

Summary

Types

request_opts()

@type request_opts() :: [
  timeout: pos_integer(),
  headers: [{String.t(), String.t()}],
  json: map(),
  body: binary()
]

response()

@type response() :: %{
  status: pos_integer(),
  headers: [{String.t(), String.t()}],
  body: binary() | map()
}

Callbacks

get(t, request_opts)

@callback get(String.t(), request_opts()) :: {:ok, response()} | {:error, term()}

post(t, request_opts)

@callback post(String.t(), request_opts()) :: {:ok, response()} | {:error, term()}

request(atom, t, request_opts)

@callback request(atom(), String.t(), request_opts()) ::
  {:ok, response()} | {:error, term()}