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 request_opts() :: [ timeout: pos_integer(), headers: [{String.t(), String.t()}], json: map(), body: binary() ]
@type response() :: %{ status: pos_integer(), headers: [{String.t(), String.t()}], body: binary() | json_term() }
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.