ExAcme.Request (ExAcme v0.5.1)
View SourceProvides functions to build and manage HTTP requests for the ACME API.
Summary
Functions
Builds a fetch request with the given URL.
Builds a named request by looking up the URL based on the given name and client.
Builds an update request with the given URL and body.
Looks up the URL associated with a given name from the client's directory.
Sends an HTTP request to the ACME API.
Types
Functions
Builds a fetch request with the given URL.
Parameters
url
: The URL to fetch.
Returns
- A request struct with the specified URL and an empty body.
@spec build_named(String.t(), body(), ExAcme.client()) :: t()
Builds a named request by looking up the URL based on the given name and client.
Parameters
name
: The name identifier for the request URL.body
: The content of the request body.client
: The client used to fetch the directory information.
Returns
- A request struct with the looked-up URL and specified body.
Builds an update request with the given URL and body.
Parameters
url
: The URL to send the update to.body
: The content of the request body.
Returns
- A request struct with the specified URL and body.
@spec lookup_named_url(String.t(), ExAcme.client()) :: String.t()
Looks up the URL associated with a given name from the client's directory.
Parameters
name
: The name identifier for the request URL.client
: The client used to fetch the directory information.
Returns
- The URL associated with the given name in the directory.
@spec send_request(t(), ExAcme.AccountKey.t() | JOSE.JWK.t(), ExAcme.client()) :: {:ok, %{body: body(), headers: map()}} | {:error, any()}
Sends an HTTP request to the ACME API.
This function handles the actual HTTP communication with the ACME server, including signing the request with the provided key, handling nonce refreshes, and processing the response.
Parameters
request
: The request struct containing URL and body.key
- The key used for authentication, it can either be anExAcme.AccountKey
or aJOSE.JWK
depending on if the account is registered or not.client
- The pid or name of the ExAcme client agent.
Returns
{:ok, %{body: body(), headers: map()}}
- On successful request.{:error, reason}
- On failure, with details about the error.