pub struct WebhookRequest { /* private fields */ }Expand description
Represents an incoming webhook request from Shopify.
This struct holds the raw request body and headers needed for verification. The body is stored as raw bytes to preserve the exact payload for HMAC computation.
§Example
use shopify_sdk::webhooks::WebhookRequest;
let request = WebhookRequest::new(
b"raw body bytes".to_vec(),
"hmac-signature".to_string(),
Some("orders/create".to_string()),
Some("example.myshopify.com".to_string()),
Some("2025-10".to_string()),
Some("webhook-123".to_string()),
);
assert_eq!(request.body(), b"raw body bytes");
assert_eq!(request.hmac_header(), "hmac-signature");Implementations§
Source§impl WebhookRequest
impl WebhookRequest
Sourcepub fn new(
body: Vec<u8>,
hmac_header: String,
topic: Option<String>,
shop_domain: Option<String>,
api_version: Option<String>,
webhook_id: Option<String>,
) -> Self
pub fn new( body: Vec<u8>, hmac_header: String, topic: Option<String>, shop_domain: Option<String>, api_version: Option<String>, webhook_id: Option<String>, ) -> Self
Creates a new webhook request with the given body and headers.
§Arguments
body- Raw request body as byteshmac_header- Value of the X-Shopify-Hmac-SHA256 headertopic- Value of the X-Shopify-Topic header (optional)shop_domain- Value of the X-Shopify-Shop-Domain header (optional)api_version- Value of the X-Shopify-API-Version header (optional)webhook_id- Value of the X-Shopify-Webhook-Id header (optional)
Sourcepub fn hmac_header(&self) -> &str
pub fn hmac_header(&self) -> &str
Returns the HMAC signature header value.
Sourcepub fn shop_domain(&self) -> Option<&str>
pub fn shop_domain(&self) -> Option<&str>
Returns the shop domain header value, if present.
Sourcepub fn api_version(&self) -> Option<&str>
pub fn api_version(&self) -> Option<&str>
Returns the API version header value, if present.
Sourcepub fn webhook_id(&self) -> Option<&str>
pub fn webhook_id(&self) -> Option<&str>
Returns the webhook ID header value, if present.
Trait Implementations§
Source§impl Clone for WebhookRequest
impl Clone for WebhookRequest
Source§fn clone(&self) -> WebhookRequest
fn clone(&self) -> WebhookRequest
Returns a duplicate of the value. Read more
1.0.0 · 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 WebhookRequest
impl RefUnwindSafe for WebhookRequest
impl Send for WebhookRequest
impl Sync for WebhookRequest
impl Unpin for WebhookRequest
impl UnwindSafe for WebhookRequest
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