servlet 1.0.0

A small application runtime with an explicit operational contract
Documentation

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 servlet::{App, Result};

#[servlet::main]
async fn main() -> Result<()> {
    App::new("hello-servlet")
        .get("/", async || "hello\n")
        .run()
        .await
}

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.

cargo new hello-servlet
cd hello-servlet
cargo add servlet \
  --git https://github.com/chimlet/servlet

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.

cargo doc --locked -p servlet \
  --all-features --no-deps --open

Licensed under MIT or Apache 2.0.