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

Copy Markdown View Source

Behaviour for HTTP clients.

Allows mocking HTTP requests in tests. Exosphere.ATProto.HTTP implements this behaviour and is the default adapter.

Summary

Types

json_term()

@type json_term() ::
  nil
  | boolean()
  | number()
  | binary()
  | [json_term()]
  | %{optional(binary()) => json_term()}

request_opts()

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

response()

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

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()}