[pmg-devel] [PATCH proxmox-acme-rs 1/1] directory: make meta object optional
Dominik Csapak
d.csapak at proxmox.com
Thu Oct 21 11:10:43 CEST 2021
some custom ACME endpoints do not have a TOS, and thus do not return
a meta property at all
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
src/directory.rs | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/directory.rs b/src/directory.rs
index 474b615..755ea8c 100644
--- a/src/directory.rs
+++ b/src/directory.rs
@@ -36,7 +36,8 @@ pub struct DirectoryData {
/// Metadata object, for additional information which aren't directly part of the API
/// itself, such as the terms of service.
- pub meta: Meta,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub meta: Option<Meta>,
}
/// The directory's "meta" object.
@@ -57,7 +58,10 @@ impl Directory {
/// Get the ToS URL.
pub fn terms_of_service_url(&self) -> Option<&str> {
- self.data.meta.terms_of_service.as_deref()
+ match &self.data.meta {
+ Some(meta) => meta.terms_of_service.as_deref(),
+ None => None,
+ }
}
/// Get the "newNonce" URL. Use `HEAD` requests on this to get a new nonce.
@@ -76,7 +80,7 @@ impl Directory {
/// Access to the in the Acme spec defined metadata structure.
/// Currently only contains the ToS URL already exposed via the `terms_of_service_url()`
/// method.
- pub fn meta(&self) -> &Meta {
- &self.data.meta
+ pub fn meta(&self) -> Option<&Meta> {
+ self.data.meta.as_ref()
}
}
--
2.30.2
More information about the pmg-devel
mailing list