pub struct Webhook { /* private fields */ }
Implementations§
Source§impl Webhook
impl Webhook
Sourcepub fn insecure(payload: &str) -> Result<Event, WebhookError>
pub fn insecure(payload: &str) -> Result<Event, WebhookError>
Construct an event from a webhook payload, ignoring the secret.
This method is considered insecure and intended for early-stage local testing only. Use construct_event for production instead.
§Errors
This function will return a WebhookError if the payload could not be parsed
Sourcepub fn construct_event(
payload: &str,
sig: &str,
secret: &str,
) -> Result<Event, WebhookError>
pub fn construct_event( payload: &str, sig: &str, secret: &str, ) -> Result<Event, WebhookError>
Construct an event from a webhook payload and signature.
§Errors
This function will return a WebhookError if:
- the provided signature is invalid
- the provided secret is invalid
- the signature timestamp is older than 5 minutes
- the payload could not be parsed
Sourcepub fn construct_event_with_timestamp(
payload: &str,
sig: &str,
secret: &str,
timestamp: i64,
) -> Result<Event, WebhookError>
pub fn construct_event_with_timestamp( payload: &str, sig: &str, secret: &str, timestamp: i64, ) -> Result<Event, WebhookError>
Construct an event from a webhook payload and signature, verifying its signature using the provided timestamp.
This is helpful for replaying requests in tests and should be avoided otherwise in production use.
§Errors
This function will return a WebhookError if:
- the provided signature is invalid
- the provided secret is invalid
- the signature timestamp is older than 5 minutes from the provided timestamp
- the payload could not be parsed
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Webhook
impl RefUnwindSafe for Webhook
impl Send for Webhook
impl Sync for Webhook
impl Unpin for Webhook
impl UnwindSafe for Webhook
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