From: Dominik Csapak <d.csapak@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH proxmox-acme-rs 1/1] directory: make meta object optional
Date: Thu, 21 Oct 2021 11:10:43 +0200 [thread overview]
Message-ID: <20211021091044.2135964-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20211021091044.2135964-1-d.csapak@proxmox.com>
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@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
next prev parent reply other threads:[~2021-10-21 9:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-21 9:10 [pmg-devel] [PATCH proxmox-acme-rs/pmg-rs] fix #3688: allow missing 'meta' property for acme directories Dominik Csapak
2021-10-21 9:10 ` Dominik Csapak [this message]
2021-10-21 9:10 ` [pmg-devel] [PATCH pmg-rs 1/1] fix #3688: handle optional meta property of the directory Dominik Csapak
2021-10-21 11:24 ` [pmg-devel] applied: [PATCH proxmox-acme-rs/pmg-rs] fix #3688: allow missing 'meta' property for acme directories Wolfgang Bumiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211021091044.2135964-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox