Axum Docs - Complete Documentation by ntxm.org

Axum Docs

Build web APIs and services in Rust with Axum: routing, handlers, extractors, middleware, state, databases, auth, WebSockets, and deployment.

Axum is a Tokio-based web framework for Rust. You write ordinary async functions as handlers, extract request data with typed extractors, and compose middleware with Tower. It stays close to the Rust async ecosystem instead of inventing a separate abstraction layer.

Prerequisites:

These docs assume you can write basic Rust and use Cargo. If you are new to Rust, start with the Rust docs first, then come back here.

Here's the path through the docs:

  1. Introduction to Axum: HTTP basics, why Axum, and how it fits with Tokio and Hyper.
  2. Environment setup: Rust toolchain, editors, and helpful crates.
  3. Creating an Axum project: Cargo project, dependencies, and your first server.
  4. Project structure: how to organize routes, handlers, and modules as the app grows.
  5. Routing: Router, method routers, path params, nest, merge, and fallbacks.
  6. Handlers: async handlers, extractor arguments, and return types.
  7. Responses: IntoResponse, JSON, status codes, and redirects.
  8. Extractors: Path, Query, Json, headers, and custom extractors.
  9. Application state: State, with_state, and shared data patterns.
  10. Middleware: Tower layers, from_fn, logging, and auth gates.
  11. Later chapters cover errors, databases, authentication, WebSockets, SSE, uploads, testing, observability, configuration, and deployment.

Introduction To Axum