Axum

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.

This section is written against axum 0.8.9 (released 2026-04-14), with axum-core 0.5.6, axum-extra 0.12.6, tokio 1.53, tower 0.5, tower-http 0.7 and hyper 1, on Rust 1.99 (edition 2024), checked on 2026-10-06. axum itself needs Rust 1.80 or later. There is no axum 0.9 or 1.0 release yet; the breaking changes already queued for 0.9 on the main branch are mentioned as upcoming where they matter, and examples follow the axum-v0.8.9 tag of the repository.

What axum is

axum is a web framework from the Tokio project. It routes HTTP requests to plain async functions, turns request parts into typed arguments through extractors, and turns return values into responses through IntoResponse — without macros. It has no middleware system of its own: every router, handler and layer is a tower Service, so the whole tower and tower-http ecosystem (timeouts, compression, tracing, CORS, rate limits) applies, and the same middleware works with tonic, hyper and AWS Lambda. Underneath, hyper speaks HTTP/1.1 and HTTP/2 and Tokio runs the tasks.

The section is for developers who know some Rust — ownership, traits, async/await — and want to build production services. Rust itself is covered in the Rust Reference; these pages link there instead of repeating it.

The Bookshelf application

The Bookshelf application: browsers and API clients reach the bookshelf-web axum service through an ingress; inside, tower layers wrap the router, handlers and repositories; the service uses PostgreSQL, Redis, a reviews service, an identity provider and an observability pipeline, and background workers consume a job queue in Postgres

Every page builds part of Bookshelf, an original library application: a catalogue of books and authors, loans with due dates, reviews, user accounts, an HTML front end with htmx, live updates over WebSockets and SSE, and the operational pieces of a real service. Its domain types (Book, Isbn, Loan) come from the shelf-core crate of the Rust Reference, so the same code sits behind a command-line tool there and behind an HTTP API here.

New here? Read in this order

  1. Introduction & Architecture and Getting Started — the stack and a first service

  2. Routing, Handlers and Extractors — the request side

  3. Responses and Error Handling — the response side

  4. State & Dependency Injection and Tower Service Model — how the pieces fit

  5. JSON REST APIs and Databases with sqlx — a first real API

  6. Writing Middleware and Applying Middleware & Ordering

  7. Then the security, web UI and operations groups below in any order; finish with Testing and Deployment.

Coming from axum 0.6 or 0.7, or from another framework? Start with Migration & Framework Comparison.

mindmap root((Axum)) Foundations Stack and Tower Getting started Project structure Requests and responses Routing Handlers and extractors Responses and errors State Middleware Writing and ordering tower-http Limits, CORS, rate limits APIs JSON REST Validation and OpenAPI GraphQL and gRPC Data sqlx and migrations SeaORM and Diesel Redis Security Sessions and passwords JWT and OAuth Authorization and hardening Web UI Templates and htmx Static files WebSockets and SSE Leptos and Dioxus Operations Jobs and clients Shutdown and config Logs, traces, metrics Testing, performance, deployment
Topic Where

Rust language, async/await, tokio, serde, error handling

Rust Reference

OAuth 2.0, OpenID Connect and JWT in depth

OAuth

CORS in the browser

CORS

Container images and Compose

Docker

Running services in a cluster

Kubernetes

SQL and PostgreSQL

SQL

Redis data structures and operations

Redis

GraphQL schemas, resolvers and clients

GraphQL

Prometheus, PromQL and alerting

Prometheus

MCP servers and AI agents in Rust (the rmcp SDK, Rig)

Model Context Protocol (MCP) and The 2026 Agent Frameworks Landscape

Other backend frameworks (FastAPI, NestJS, Spring Boot, ASP.NET Core, Laravel)

Backend Development and Migration & Framework Comparison

A comparison of backend and web frameworks across languages is planned (issue #263).

Bibliography

Books

  • Indo Yoon (technical reviewer Joshua Mo), Beginning Axum: Learning Modern Web Development With Rust, 1st edition. Apress, 2026. ISBN 979-8-8688-2630-6 (print), 979-8-8688-2631-3 (eBook), DOI 10.1007/979-8-8688-2631-3. Publisher page; companion code and chat application.

  • Manjunath Gangappa and Rajkumar Rangaraj (foreword by Trask Stalnaker), Mastering Distributed Observability in Rust: Implement OpenTelemetry in a real-world, multi-container e-commerce architecture, 1st edition. Packt, 2026 (June). ISBN 978-1-80667-179-3 (print); eBook ISBN 978-1-80667-178-6 as given by retailer listings. Publisher page; companion code.

  • Nouman Azam, Advanced Rust: Exploring Power Features of Rust for Intermediate and Advanced Developers, 1st edition (technical reviewer Yogendra Sharma). Apress, 2026. ISBN 979-8-8688-2991-8 (print), 979-8-8688-2992-5 (eBook), DOI 10.1007/979-8-8688-2992-5. Publisher page. Chapter 2 (debugging and tracing) was used for this section.

  • Ethan Crossley, Hayden Van Der Post and Alice Schwartz (credited inconsistently), Rust for Scientific Computing: Numerical Methods, Simulations, and Linear Algebra. Reactive Publishing, 2026. No ISBN is printed; retailers list the paperback as 979-8-19849-392-6. Publisher site. Consulted for topic coverage only: no facts or code were taken from it. Its chapter 15 web-service example is cited only where it shows outdated axum code (axum::Server, AddExtensionLayer, /:id routes).

The books are consulted references, not the primary source. On any discrepancy, and wherever a book is silent on a later feature, the official documentation wins; where a book shows an outdated form, the pages say so in prose (collected on Migration & Framework Comparison).

Crates and services used on the pages