Module axum
Web application framework built on tokio and hyper.
axum is a web framework from the tokio project.
It follows a typical router + middleware design.
It is the preeminent web framework through its association
with tokio. The API is async and highly generic,
advanced Rust.
- Handlers are plain async functions, not trait impls
- Request data is accessed through extractor types like
Path,Query, andJson - Responses are any type that implements
IntoResponse - Middleware uses the
towerServicetrait, composable with the wider Tower ecosystem - Shared application state is passed via
State
Examples
A minimal server:
use ;
use TcpListener;
async
async
async
Handling JSON request and response bodies:
use ;
use ;
async
async
Modules
- body HTTP body utilities.
- error_handling Error handling model and utilities
- extract Types and traits for extracting data from requests.
- handler Async functions that can be used to handle requests.
- middleware Utilities for writing middleware
- response Types and traits for generating responses.
-
routing
Routing between
Services and handlers. - serve Serve services.