pub struct WebhookHeaders {
pub id: String,
pub timestamp: String,
pub signature: String,
}Expand description
The three headers required to verify a webhook, looked up case-insensitively
by the caller before constructing this struct:
webhook-id, webhook-timestamp, webhook-signature.
Fields§
§id: StringValue of the webhook-id header.
timestamp: StringValue of the webhook-timestamp header (kept as the original string;
it is used verbatim when building the signed payload).
signature: StringValue of the webhook-signature header (one or more space-separated
signatures, each optionally prefixed with "v1,").
Implementations§
Source§impl WebhookHeaders
impl WebhookHeaders
Sourcepub fn new(
id: impl Into<String>,
timestamp: impl Into<String>,
signature: impl Into<String>,
) -> Self
pub fn new( id: impl Into<String>, timestamp: impl Into<String>, signature: impl Into<String>, ) -> Self
Convenience constructor.
Sourcepub fn from_lookup(
get: impl Fn(&str) -> Option<String>,
) -> Result<Self, WebhookVerificationError>
pub fn from_lookup( get: impl Fn(&str) -> Option<String>, ) -> Result<Self, WebhookVerificationError>
Extract the three webhook-* headers via a lookup function, so any
HTTP framework’s header map plugs in without a dependency here:
let headers = WebhookHeaders::from_lookup(|name| get_header(name))
.expect("missing webhook headers");Lookups are performed with lowercase header names.
Trait Implementations§
Source§impl Clone for WebhookHeaders
impl Clone for WebhookHeaders
Source§fn clone(&self) -> WebhookHeaders
fn clone(&self) -> WebhookHeaders
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WebhookHeaders
impl RefUnwindSafe for WebhookHeaders
impl Send for WebhookHeaders
impl Sync for WebhookHeaders
impl Unpin for WebhookHeaders
impl UnsafeUnpin for WebhookHeaders
impl UnwindSafe for WebhookHeaders
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more