Servlet
Servlet runs Axum routes and supervises background workers on Tokio. It starts serving requests once workers are ready and health checks pass. On shutdown, it drains in-flight requests.
use ;
async
Pass an existing router to App::http. Register long-running tasks with App::worker.
Run the example
Create a project with Rust 1.97 or later.
Save the example as src/main.rs and start it with cargo run. Call the route from another terminal.
$ curl http://127.0.0.1:8080/
hello
Health and metrics
The app listens on 127.0.0.1:8080 by default. Set SERVLET_BIND to change its address.
Set SERVLET_ADMIN_BIND=127.0.0.1:9090 for a separate admin listener. It serves /live, /ready, and Prometheus metrics at /metrics.
Optional features
| Feature | Adds |
|---|---|
client |
Pooled HTTP requests with deadlines and body limits |
postgres |
SQLx connection pools with readiness checks |
otel |
OpenTelemetry trace export over OTLP/HTTP |
recourse |
Typed HTTP errors with request IDs |
Open the API reference from the repository root.
Licensed under MIT or Apache 2.0.