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
Types
@type json_term() :: Exosphere.ATProto.HTTP.Behaviour.json_term()
@type request_opts() :: Exosphere.ATProto.HTTP.Behaviour.request_opts()
@type response() :: Exosphere.ATProto.HTTP.Behaviour.response()
Functions
@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
@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
@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.