Skip to main content

WebhookEndpoint

Struct WebhookEndpoint 

Source
pub struct WebhookEndpoint { /* private fields */ }
Expand description

Verification rules for one inbound webhook route or prefix.

Implementations§

Source§

impl WebhookEndpoint

Inherent preset constructors and fluent builders for WebhookEndpoint.

Source

pub fn new<P, H>( path_prefix: P, signature_header: H, scheme: WebhookScheme, secrets: Vec<WebhookSecret>, ) -> Self
where P: Into<String>, H: AsRef<str>,

Creates a webhook endpoint verifying scheme signatures delivered in signature_header.

§Arguments
  • P - Route path or prefix (for example "/webhooks/events").
  • H - Signature request header name.
  • WebhookScheme - Signature encoding/framing scheme.
  • Vec<WebhookSecret> - Active signing secrets (supports rotation).
§Returns
  • Self - Constructed endpoint definition.
Source

pub fn stripe<P>(path_prefix: P, secrets: Vec<WebhookSecret>) -> Self
where P: Into<String>,

Preset for Stripe-style Stripe-Signature: t=...,v1=... timestamped webhooks.

§Arguments
  • P - Route path or prefix (for example "/webhooks/stripe").
  • Vec<WebhookSecret> - Active Stripe signing secrets.
§Returns
  • Self - Stripe-compatible endpoint configuration.
Source

pub fn github<P>(path_prefix: P, secrets: Vec<WebhookSecret>) -> Self
where P: Into<String>,

Preset for GitHub X-Hub-Signature-256: sha256=<hex> webhooks with X-GitHub-Delivery replay defense.

§Arguments
  • P - Route path or prefix (for example "/webhooks/github").
  • Vec<WebhookSecret> - Active GitHub webhook secrets.
§Returns
  • Self - GitHub-compatible endpoint configuration.
Source

pub fn shopify<P>(path_prefix: P, secrets: Vec<WebhookSecret>) -> Self
where P: Into<String>,

Preset for Shopify X-Shopify-Hmac-Sha256: <base64> webhooks.

§Arguments
  • P - Route path or prefix (for example "/webhooks/shopify").
  • Vec<WebhookSecret> - Active Shopify webhook secrets.
§Returns
  • Self - Shopify-compatible endpoint configuration.
Source

pub fn with_secret(self, secret: WebhookSecret) -> Self

Appends an additional active secret key for zero-downtime key rotation.

§Arguments
  • WebhookSecret - Rotated or secondary signing secret.
§Returns
  • Self - Updated endpoint.
Source

pub fn with_timestamp_header<H>( self, header: H, separator: Option<String>, ) -> Self
where H: AsRef<str>,

Configures a separate Unix-seconds timestamp header and optional <ts><sep><body> signing separator.

§Arguments
  • H - Timestamp request header name.
  • Option<String> - Separator inserted between timestamp and body when signing (or None to sign raw body only).
§Returns
  • Self - Updated endpoint.
Source

pub fn with_id_header<H>(self, header: H) -> Self
where H: AsRef<str>,

Configures the delivery identifier header used as the replay-cache nonce.

§Arguments
  • H - Delivery ID header name (for example "x-github-delivery" or "webhook-id").
§Returns
  • Self - Updated endpoint.
Source

pub fn with_tolerance_secs(self, tolerance_secs: u64) -> Self

Sets the allowed timestamp skew tolerance in seconds (±tolerance_secs).

§Arguments
  • u64 - Tolerance window in seconds.
§Returns
  • Self - Updated endpoint.
Source

pub fn with_replay_ttl_secs(self, replay_ttl_secs: u64) -> Self

Sets the replay-nonce cache TTL in seconds (0 disables replay caching for this endpoint).

§Arguments
  • u64 - Replay retention TTL in seconds.
§Returns
  • Self - Updated endpoint.
Source

pub fn with_max_body_bytes(self, max_body_bytes: usize) -> Self

Sets the maximum inbound webhook payload length in bytes.

§Arguments
  • usize - Maximum body bytes (>= 1).
§Returns
  • Self - Updated endpoint.
Source§

impl WebhookEndpoint

Source

pub fn get_path_prefix(&self) -> &String

Source

pub fn get_mut_path_prefix(&mut self) -> &mut String

Source

pub fn set_path_prefix(&mut self, val: String) -> &mut Self

Source

pub fn get_signature_header(&self) -> &String

Source

pub fn get_mut_signature_header(&mut self) -> &mut String

Source

pub fn set_signature_header(&mut self, val: String) -> &mut Self

Source

pub fn get_scheme(&self) -> &WebhookScheme

Source

pub fn get_mut_scheme(&mut self) -> &mut WebhookScheme

Source

pub fn set_scheme(&mut self, val: WebhookScheme) -> &mut Self

Source

pub fn get_secrets(&self) -> &Vec<WebhookSecret>

Source

pub fn get_mut_secrets(&mut self) -> &mut Vec<WebhookSecret>

Source

pub fn set_secrets(&mut self, val: Vec<WebhookSecret>) -> &mut Self

Source

pub fn get_timestamp_header(&self) -> Option<String>

Source

pub fn try_get_timestamp_header(&self) -> Option<String>

Source

pub fn get_mut_timestamp_header(&mut self) -> &mut Option<String>

Source

pub fn set_timestamp_header(&mut self, val: Option<String>) -> &mut Self

Source

pub fn get_timestamp_payload_separator(&self) -> Option<String>

Source

pub fn try_get_timestamp_payload_separator(&self) -> Option<String>

Source

pub fn get_mut_timestamp_payload_separator(&mut self) -> &mut Option<String>

Source

pub fn set_timestamp_payload_separator( &mut self, val: Option<String>, ) -> &mut Self

Source

pub fn get_id_header(&self) -> Option<String>

Source

pub fn try_get_id_header(&self) -> Option<String>

Source

pub fn get_mut_id_header(&mut self) -> &mut Option<String>

Source

pub fn set_id_header(&mut self, val: Option<String>) -> &mut Self

Source

pub fn get_tolerance_secs(&self) -> u64

Source

pub fn get_mut_tolerance_secs(&mut self) -> &mut u64

Source

pub fn set_tolerance_secs(&mut self, val: u64) -> &mut Self

Source

pub fn get_replay_ttl_secs(&self) -> u64

Source

pub fn get_mut_replay_ttl_secs(&mut self) -> &mut u64

Source

pub fn set_replay_ttl_secs(&mut self, val: u64) -> &mut Self

Source

pub fn get_max_body_bytes(&self) -> usize

Source

pub fn get_mut_max_body_bytes(&mut self) -> &mut usize

Source

pub fn set_max_body_bytes(&mut self, val: usize) -> &mut Self

Trait Implementations§

Source§

impl Clone for WebhookEndpoint

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WebhookEndpoint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for WebhookEndpoint

Source§

impl PartialEq for WebhookEndpoint

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for WebhookEndpoint

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnySend for T
where T: Any + Send,

Source§

impl<T> AnySendClone for T
where T: Any + Send + Clone,

Source§

impl<T> AnySendSync for T
where T: Any + Send + Sync,

Source§

impl<T> AnySendSyncClone for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> AnySync for T
where T: Any + Sync,

Source§

impl<T> AnySyncClone for T
where T: Any + Sync + Clone,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more