Handle Subscription Cancel in Rust Actix Web

Actix-web developers utilizing Comora utilize its `event_handler` macro to define asynchronous functions that listen for subscription cancellation events from external systems like Stripe. Comora then automatically generates the necessary Rust code for handling these events, including integrating with the Actix-Web runtime, managing state, and triggering downstream workflows like updating databases and sending notifications – all without manual boilerplate.

Zero Boilerplate

Stop writing the same event handlers over and over. Comorando executes your logic automatically.

Smart Retries

Exponential backoff, dead-letter queues, and alert escalation — built in, no config needed.

AI Decisions

Gemma 4 evaluates every event and suggests the optimal action based on your business rules.

Code Example

// actix-web — subscription-cancel handler with Comorando
use actix_web::{post, web, HttpRequest, HttpResponse};
use comorando::Client as Comorando;

#[post("/webhook")]
async fn webhook(req: HttpRequest, body: web::Bytes) -> HttpResponse {
    let sig = req.headers().get("stripe-signature").unwrap().to_str().unwrap();
    let event = stripe::Webhook::construct_event(&body, sig, &WEBHOOK_SECRET).unwrap();

    // Comorando evaluates rules and fires actions automatically
    let comorando = Comorando::new(&std::env::var("COMORANDO_API_KEY").unwrap());
    comorando.decisions().create(json!({
        "event":  event.event_type,
        "data":   event.data.object,
        "org_id": std::env::var("COMORANDO_ORG_ID").unwrap()
    })).await.unwrap();
    HttpResponse::Ok().json(serde_json::json!({"received": true}))
}

Automate your backend events today

Free tier includes 10,000 events/month. No credit card required.

Start Free See Pricing