Crate Actix Web

Chester Wyke December 15, 2023 Updated: April 15, 2025 #rust

Website: https://actix.rs/

List of useful doc items

Log (record) unmatched routes

Add a default service and route (This example uses tracing to do the recording)

default_service(web::route().to(not_found)); // Added into config

#[tracing::instrument]
pub async fn not_found(req: HttpRequest) -> actix_web::Result<HttpResponse> {
    error!("Failed to match route");
    Ok(HttpResponse::NotFound().body("404 - Not found\n"))
}

Graceful shutdown

There are multiple references I found and the appropriate one depends on your use case. I’m collecting them here because I don’t want to have to search for them again. I recommend also checking out Tokio Cancellation Tokens as well as applicable to your use case.

Resources: