pub struct Client { /* private fields */ }Expand description
ACME HTTP Client
The client handles sending ACME HTTP requests, and providing ACME HTTP
responses using the crate::Request and crate::Response objects
respectively.
§Example
You can use a Client to send HTTP requests to an ACME provider, using either
Client::get to send a plain HTTP GET request, or Client::execute to
send a signed ACME HTTP request.
See crate::Request for more information on how to create a request.
let key = Arc::new(SignatureKind::Ecdsa(yacme_key::EcdsaAlgorithm::P256).random());
let mut client = Client::default();
client.set_new_nonce_url("https://acme.example.com/new-nonce".parse().unwrap());
let request = Request::get("https://acme.example.com/account/1".parse().unwrap(), key);
// This would normally be an actual response payload type, and not serde_json::Value.
let response: Response<serde_json::Value> = client.execute(request).await?;
Implementations§
Source§impl Client
impl Client
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Create a new client builder to configure a client.
Sourcepub fn set_new_nonce_url(&mut self, url: Url)
pub fn set_new_nonce_url(&mut self, url: Url)
Set the URL used for fetching a new Nonce from the ACME provider.
Source§impl Client
impl Client
Sourcepub async fn get<R>(&mut self, url: Url) -> Result<Response<R>, AcmeError>where
R: Decode,
pub async fn get<R>(&mut self, url: Url) -> Result<Response<R>, AcmeError>where
R: Decode,
Run a plain HTTP GET request without using the ACME HTTP JWS
protocol.
Sourcepub async fn execute<P, R>(
&mut self,
request: Request<P>,
) -> Result<Response<R>, AcmeError>
pub async fn execute<P, R>( &mut self, request: Request<P>, ) -> Result<Response<R>, AcmeError>
Execute an HTTP request using the ACME protocol.
See crate::Request for more information on how to create a request.
Request payloads must be serializable, and request responses must implement Decode.
Decode is implemented for all types that implement serde::Deserialize.