ExAcme.Request (ExAcme v0.5.2)

View Source

Provides functions to build and manage HTTP requests for the ACME API.

Attributes

  • url - The target URL for the request
  • body - The request body content (string or map)

Summary

Types

The type of the request body.

t()

Request object

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

body()

@type body() :: String.t() | map()

The type of the request body.

t()

@type t() :: %ExAcme.Request{body: body(), url: String.t()}

Request object

Functions

build_fetch(url)

@spec build_fetch(String.t()) :: t()

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.

build_named(name, body, client)

@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.

build_update(url, body)

@spec build_update(String.t(), body()) :: t()

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.

lookup_named_url(name, client)

@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.

send_request(request, key, client)

@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 an ExAcme.AccountKey or a JOSE.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.