Axum is a Rust library for routing HTTP requests, parsing them with extractors, handling errors predictably, and composing Tower middleware with minimal handler boilerplate.
Overview
Axum focuses on ergonomics and modularity for HTTP servers written in Rust. Handlers are wired through a macro-free routing API, while extractors declaratively pull data from incoming requests. Responses can be built with little ceremony, and errors follow a simple, predictable model.
Rather than a bespoke middleware stack, Axum builds on Tower services, which lets applications reuse timeouts, tracing, compression, authorization, and other Tower HTTP utilities. Middleware can also be shared with Hyper- or Tonic-based programs because the same service abstraction applies across the ecosystem.
The crate layers on top of Hyper with thin overhead; published benchmarks report performance comparable to Hyper. The codebase forbids unsafe Rust.
Runnable examples and community help channels support adoption. Developers choose Axum when they want a Rust web layer that leans on Tower for cross-project middleware reuse instead of inventing a separate middleware system.
Key features
- Macro-free route definitions
- Declarative request extractors
- Predictable error handling model
- Minimal-boilerplate responses
- Tower and Tower HTTP middleware
- Hyper-based performance profile
- Shared middleware with Hyper apps
- Forbid-unsafe-code implementation
Use cases
- Rust HTTP APIs and microservices
- Tower middleware composition
- Shared auth across Hyper services
- Extractor-driven request parsing
- Tracing and compression via Tower