pub struct Receiver { /* private fields */ }Implementations§
Source§impl Receiver
impl Receiver
pub fn new( gateway: Arc<dyn Gateway>, log: Arc<dyn WebhookLog>, handler: impl Fn(WebhookEvent) -> BoxFuture<Result<()>> + Send + Sync + 'static, ) -> Receiver
Sourcepub async fn deliver(&self, headers: &Headers, body: &[u8]) -> Handled
pub async fn deliver(&self, headers: &Headers, body: &[u8]) -> Handled
Process one delivery. Separated from the HTTP handler so it can be tested without a request, and so a replay tool can call it.
Sourcepub async fn handle(&self, request: Request) -> Response
pub async fn handle(&self, request: Request) -> Response
The route handler: mount it at whatever path the gateway was given.
ⓘ
let receiver = Arc::new(Receiver::new(gateway, log, |event| Box::pin(async move { … })));
r.post("/webhooks/payment", move |req: Request| {
let receiver = Arc::clone(&receiver);
async move { receiver.handle(req).await }
});Behind no CSRF and no session middleware: the caller is a server with a signature, and a CSRF check would refuse it every time.
Auto Trait Implementations§
impl !RefUnwindSafe for Receiver
impl !UnwindSafe for Receiver
impl Freeze for Receiver
impl Send for Receiver
impl Sync for Receiver
impl Unpin for Receiver
impl UnsafeUnpin for Receiver
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