Axum Cheat Sheet
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. The reference material consulted while preparing these pages is listed in the section bibliography. |
A single-page, colour-coded summary of web development with axum, written against axum 0.8.9, tokio 1.53 and tower-http
0.7.1 on Rust 1.99 (checked 2026-10-06) — the tokio, hyper, tower and axum stack with a request’s life, the Cargo.toml
and main.rs skeleton with axum::serve and graceful shutdown, routing with {param} and {*rest} captures, nest,
merge and fallbacks, the extractor table with the body-extractor-last rule and optional extractors, responses and an
AppError recipe, State, FromRef and Extension, middleware with from_fn and the layer-ordering rules, the
tower-http layers with body limits, timeouts and CORS, validation and utoipa snippets, sqlx pool, query, transaction and
migration one-liners, a sessions, passwords, JWT, OAuth2 and CSRF checklist, askama with htmx, WebSocket, SSE and
multipart skeletons, tracing, OpenTelemetry and metrics setup, testing with oneshot and axum-test, a deployment
checklist, and a strip of what changed since older tutorials — handy for quick memorization or as a
downloadable PDF desk reference.
For the full explanation, every option, and additional examples, see the dedicated pages:
Start here — Axum.
Foundations — Introduction & Architecture, Tower Service Model, Getting Started and Project Structure.
Routing, handlers, extractors and responses — Routing, Routing Composition, Handlers, Extractors, Custom Extractors, axum-extra, Responses, Error Handling and State & Dependency Injection.
Middleware and HTTP concerns — Writing Middleware, Applying Middleware & Ordering, tower-http Catalog, Request Limits & Timeouts, CORS & Compression and Rate Limiting & Load Shedding.
Building APIs — JSON REST APIs, Validation, OpenAPI with utoipa, Forms & Content Negotiation and GraphQL & gRPC.
Security — Sessions & Cookies, Password Authentication, JWT & Bearer Tokens, OAuth2 & OpenID Connect, Authorization, CSRF & Security Hardening and TLS & HTTPS.
Web UI and real-time — Server-side Templates, htmx, Static Files & SPAs, WebSockets, Server-Sent Events & Streaming, File Uploads and Full-stack with Leptos & Dioxus.
Operations — Background Jobs & Tasks, HTTP Clients & Proxies, Graceful Shutdown, Configuration, Logging & Tracing, OpenTelemetry & Distributed Tracing, Metrics & SLOs, Testing, Performance Tuning and Deployment.
Reference — Migration & Framework Comparison.
References
The PDF summarizes the official documentation; each source is cited in full on the page listed above that covers it, and in the section bibliography.