Exosphere.ATProto.HTTP (Exosphere v0.6.0)

Copy Markdown View Source

Simple HTTP client using Mint.

Provides a high-level API for making HTTP requests using Mint under the hood. Each request opens a new connection (suitable for infrequent requests to many different hosts, as is common in Exosphere.ATProto).

Examples

{:ok, response} = Exosphere.ATProto.HTTP.get("https://plc.directory/did:plc:abc")
{:ok, response} = Exosphere.ATProto.HTTP.post("https://pds.example.com/xrpc/...", json: %{})

Summary

Functions

Make an HTTP GET request.

Make an HTTP POST request.

Make a generic HTTP request.

Types

json_term()

request_opts()

response()

Functions

get(url, opts \\ [])

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

Make an HTTP GET request.

Options

  • :timeout - Request timeout in milliseconds (default: 30_000)
  • :headers - Additional headers to send

post(url, opts \\ [])

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

Make an HTTP POST request.

Options

  • :timeout - Request timeout in milliseconds (default: 30_000)
  • :headers - Additional headers to send
  • :json - Map to encode as JSON body
  • :body - Raw binary body

request(method, url, opts \\ [])

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

Make a generic HTTP request.

GET/HEAD redirects (301/302/303/307/308) are followed automatically, up to 5 hops. This matters for atproto endpoints: a relay may redirect com.atproto.sync.getRepo to the PDS that actually hosts the account. Redirect handling can be disabled with follow_redirects: false.