pub struct WebhookRequest { /* private fields */ }Expand description
Raw HTTP webhook request data.
Contains the headers and body from an incoming GitHub webhook HTTP request.
Headers should include X-GitHub-Event, X-GitHub-Delivery, and
X-Hub-Signature-256.
§Examples
use github_bot_sdk::webhook::WebhookRequest;
use std::collections::HashMap;
let headers = HashMap::from([
("x-github-event".to_string(), "pull_request".to_string()),
("x-github-delivery".to_string(), "12345".to_string()),
]);
let body = b"{\"action\":\"opened\"}".to_vec();
let request = WebhookRequest::new(headers, body.into());
assert_eq!(request.event_type(), Some("pull_request"));Implementations§
Source§impl WebhookRequest
impl WebhookRequest
Sourcepub fn new(headers: HashMap<String, String>, body: Bytes) -> Self
pub fn new(headers: HashMap<String, String>, body: Bytes) -> Self
Create a new webhook request.
§Arguments
headers- HTTP headers (case-insensitive keys recommended)body- Raw webhook payload bytes
Sourcepub fn event_type(&self) -> Option<&str>
pub fn event_type(&self) -> Option<&str>
Get the event type from X-GitHub-Event header.
Sourcepub fn delivery_id(&self) -> Option<&str>
pub fn delivery_id(&self) -> Option<&str>
Get the delivery ID from X-GitHub-Delivery header.
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 UnsafeUnpin 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