Skip to main content

Webhook

Trait Webhook 

Source
pub trait Webhook:
    Send
    + Sync
    + 'static {
    const PROVIDER: &'static str;

    // Required methods
    fn verify(request: &WebhookRequest, state: &AppState) -> Result;
    fn event_id(request: &WebhookRequest) -> Result<String>;
    fn handle(
        call: WebhookCall,
        ctx: JobContext,
    ) -> impl Future<Output = Result> + Send;
}
Expand description

Tells Renox how to receive one provider’s webhooks.

Required Associated Constants§

Source

const PROVIDER: &'static str

A short, stable name such as "midtrans"; stored with each call.

Required Methods§

Source

fn verify(request: &WebhookRequest, state: &AppState) -> Result

Accepts the call only if it really comes from the provider, usually by checking a signature over WebhookRequest::body. An error answers 401 and nothing is stored.

Source

fn event_id(request: &WebhookRequest) -> Result<String>

The provider’s id for this event. A call whose id was seen before is answered 200 without being processed again. Include the status when a provider sends several calls for one object (e.g. "{id}:{status}").

Source

fn handle( call: WebhookCall, ctx: JobContext, ) -> impl Future<Output = Result> + Send

Processes a stored call in a queue worker. An error marks the call failed and retries it (five attempts in all).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§