Skip to content
CAI
Software that uses CAICheck a score

tokio-rs/axum

50.1

Adequate · 14 November 2026

32.1k

lines of production code

Rust

primary language

7

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

Features

Add InnerPath extractor for scoped path parameter extraction

Axum now provides an \InnerPath\ extractor that retrieves URL path parameters only from the innermost matched router, excluding captures from parent \nest\ routes. This allows handlers to remain agnostic of their nesting context, whereas the existing \Path\ extractor continues to return all captures in the request path. The implementation includes a dedicated deserializer (\de.rs\) and rejection types to handle parsing and validation for this new scoped extraction.

axum/src/extract/path · high confidence

Add MiniJinja templating example

A new example demonstrating how to integrate the MiniJinja templating engine with an Axum application. It provides a runnable demo featuring a shared layout and three pages (Home, Content, About) that render HTML templates using context data.

examples/templates-minijinja · high confidence

Add MongoDB integration example

A new example application demonstrating how to integrate Axum with MongoDB has been added. It provides a complete CRUD (Create, Read, Update, Delete) service for a 'Member' entity, showcasing route definitions, state management via the MongoDB driver, and request/response handling with JSON serialization.

examples/mongodb · high confidence

Add PrivateCookieJar and SignedCookieJar extractors with feature-gated availability

axum-extra now provides \PrivateCookieJar\ and \SignedCookieJar\ extractors for handling encrypted and signed cookies, respectively. These types are gated behind the \cookie-private\ and \cookie-signed\ Cargo features and require a cryptographic \Key\ to be available in the application state via \FromRef\. Users must return the updated jar from their handlers to propagate cookie changes, and the \cookie-key-expansion\ feature is required if using \Key::derive\_from\.

axum-extra/src/extract/cookie · high confidence

Add Prometheus metrics example for Axum applications

A new example demonstrating how to integrate Prometheus metrics with Axum has been added. It shows how to track HTTP request counts and latencies using a custom middleware, configure Prometheus buckets, and run a separate server on port 3001 to expose the /metrics endpoint while the main application runs on port 3000.

examples/prometheus-metrics · high confidence

Add README example project

A new example project has been added to demonstrate the core functionality of the library. It provides a runnable Rust application that sets up a router with GET and POST endpoints, handles JSON request bodies, and serves the application using the \axum::serve\ function.

examples/readme · high confidence

Add SQLx PostgreSQL example with connection pool and custom extractor

The \examples/sqlx-postgres\ directory now contains a complete example application demonstrating how to integrate Axum with SQLx for PostgreSQL. The example shows how to set up a \PgPool\ connection pool, configure tracing, and serve HTTP routes. It illustrates two approaches for database access: using Axum's built-in \State\ extractor to share the pool across handlers, and implementing a custom \FromRequestParts\ extractor (\DatabaseConnection\) to acquire individual connections from the pool on demand.

examples/sqlx-postgres · high confidence

Add SSE example with integration tests

The SSE example now includes a complete implementation featuring a server that streams events every second with a keep-alive mechanism, serves static assets (HTML/JS) for client-side consumption, and provides an integration test to verify the event stream functionality.

examples/sse · high confidence

Add TLS graceful shutdown example with HTTP-to-HTTPS redirect

The \examples/tls-graceful-shutdown\ directory now includes a complete runnable example demonstrating how to handle graceful shutdowns in an Axum application. The example features an HTTPS server using Rustls for TLS termination and a separate HTTP server that automatically redirects incoming requests to the HTTPS endpoint. It includes self-signed certificates for local testing and implements signal handling (Ctrl+C and Unix terminate signals) to ensure the server shuts down gracefully within a specified timeout.

examples/tls-graceful-shutdown · high confidence

Add WASM serverless example for axum

A new example (\examples/simple-router-wasm\) demonstrates how to run axum in a WebAssembly context (target \wasm32-unknown-unknown\). It shows a minimal serverless-style setup where a \Router\ handles a request and returns a response, noting that \default-features = false\ is required because tokio's IO layer (mio) does not support the WASM target.

examples/simple-router-wasm · high confidence

Add auto-reload example for development workflows

A new example demonstrating how to set up a development environment for an Axum service that automatically recompiles and restarts upon source code changes. The example utilizes \listenfd\ to migrate connections from an old version of the app to the newly compiled version, ensuring minimal downtime during development.

examples/auto-reload · high confidence

Add compression example demonstrating request decompression and response compression

The \examples/compression\ directory now includes a runnable example that demonstrates how to automatically decompress request bodies (gzip, brotli, zstd) and compress response bodies based on the client's \Accept-Encoding\ header. The example uses \tower-http\'s \RequestDecompressionLayer\ and \CompressionLayer\ within an Axum router, and includes tests verifying correct handling of both compressed and uncompressed payloads.

examples/compression · high confidence

Add dependency injection example

A new example application has been added to demonstrate two approaches to dependency injection in Axum: using trait objects (\dyn UserRepo\) and using generics (\T: UserRepo\). The example implements an in-memory user repository and exposes routes under \/dyn\ and \/generic\ paths to illustrate the trade-offs between dynamic dispatch and static dispatch in terms of code complexity and flexibility.

(repo-wide) · high confidence

Add diesel-postgres example application

A new example application demonstrating how to integrate Axum with Diesel and PostgreSQL has been added. This example includes a complete setup with database migrations, a connection pool using deadpool-diesel, and REST endpoints for creating and listing users, providing a reference implementation for building data-driven web services.

examples/diesel-postgres · high confidence

Add example for consuming request body in middleware and extractor

A new example demonstrates how to consume the HTTP request body upfront within both a middleware and a custom extractor. The middleware buffers the body into bytes before passing the request downstream, while the custom \BufferRequestBody\ extractor implements \FromRequest\ to collect the body payload, allowing users to inspect or process the full request content before it reaches the final handler.

examples/consume-body-in-extractor-or-middleware · high confidence

Add example for defining routes and handlers close together

A new example demonstrates how to define routes and their corresponding handlers in close proximity within the same module. The example shows creating a Router by merging separate route definitions for root, GET /foo, and POST /foo, and serving the application using the \axum::serve\ function.

examples/routes-and-handlers-close-together · high confidence

Add example for handling anyhow::Error in Axum responses

A new example demonstrates how to integrate the \anyhow\ crate with Axum by wrapping \anyhow::Error\ in a custom \AppError\ type that implements \IntoResponse\. This allows handlers to use the \?\ operator with \anyhow\-returning functions while ensuring errors are converted into a consistent 500 Internal Server Error response with a descriptive message. The example includes a test verifying this error-handling behavior.

examples/anyhow-error-response · high confidence

Add example for parsing request body based on Content-Type

Introduces a new example demonstrating how to create a custom extractor that automatically parses incoming request bodies as either JSON or form data depending on the Content-Type header. This allows API endpoints to handle multiple content formats seamlessly without requiring clients to specify a single strict format.

examples/parse-body-based-on-content-type · high confidence

Add example for proxying reqwest responses

A new example application demonstrates how to proxy a \reqwest::Response\ within an Axum service. The example shows how to forward the upstream status code and headers, and stream the response body using \Body::from\_stream\, while also including a simple streaming endpoint and HTTP tracing for debugging.

examples/reqwest-response · high confidence

Add initial performance benchmarks for axum

A new benchmark suite has been added to the axum crate to measure performance across various routing and handling scenarios. The benchmarks cover minimal setups, basic routing, route merging and nesting, complex routing tables, JSON request/response handling, and the use of Extensions and State. This allows developers to track performance regressions or improvements in these core areas.

axum/benches · high confidence

Add low-level OpenSSL example for Axum 0.7

A new example demonstrating how to integrate OpenSSL for TLS with Axum 0.7 has been added to the repository. This example includes a complete Rust source file and self-signed certificate/key pairs, showing users how to manually handle TLS handshakes using \tokio-openssl\ and \hyper-util\ alongside an Axum router.

examples/low-level-openssl · high confidence

Add request-id example demonstrating request ID propagation

A new example application has been added at examples/request-id that demonstrates how to generate unique request IDs using tower-http's MakeRequestUuid and propagate them from request headers to response headers. The example also shows how to include the request ID in trace spans for better observability.

examples/request-id · high confidence

Add stream-to-file example demonstrating secure file uploads

The \examples/stream-to-file\ example has been added, providing a reference implementation for handling file uploads via HTTP. It demonstrates how to stream request bodies and multipart form fields directly to disk using \tokio\ and \axum\, including a specific \path\_is\_valid\ check to prevent directory traversal attacks by ensuring uploaded filenames contain only a single normal path component.

examples/stream-to-file · high confidence

Add tokio-redis example with connection pooling

A new example application has been added at examples/tokio-redis that demonstrates integrating Axum with Redis using the redis crate and bb8 for connection pooling. The example includes a custom extractor (DatabaseConnection) to fetch connections from the pool and shows how to set up tracing with environment-based filtering.

examples/tokio-redis · high confidence

Add utility to convert HTTP body to bytes with size limiting

A new \to\_bytes\ function is now available in the \axum::body\ module, allowing users to convert an HTTP body into a \Bytes\ slice while enforcing a configurable maximum size limit. This utility simplifies reading request or response bodies by handling the collection and size-checking logic, returning an error if the body exceeds the specified limit.

axum/src/body · high confidence

Example demonstrating custom path rejection error handling

The \examples/customize-path-rejection\ example now shows how to implement a custom \Path\ extractor that overrides the default error response. It maps specific \PathRejection\ variants (such as wrong parameter counts, parse errors, or invalid UTF-8) to tailored JSON error bodies containing a message and optional location, and upgrades unsupported-type errors to a 500 Internal Server Error status.

examples/customize-path-rejection · high confidence

Example demonstrating explicit HEAD request handling

A new example in \examples/handle-head-request\ shows how to explicitly handle HTTP HEAD requests by extracting the \http::Method\ from the request context. The example illustrates a pattern where HEAD requests return specific headers without executing the full body-generation logic used by GET requests, and includes tests verifying both GET and implicit HEAD behaviors.

examples/handle-head-request · high confidence

Expanded static-file-server example with multiple serving strategies

The static-file-server example has been significantly expanded to demonstrate various ways to serve static assets using \tower-http\ services. It now includes runnable configurations for serving directories via \ServeDir\, handling Single Page Application (SPA) fallbacks with \ServeFile\ and status code manipulation, nesting multiple serve directories, integrating custom handlers as fallback services, and calling \ServeDir\ directly from within a handler. The example also includes tests to verify correct fallback behavior.

examples/static-file-server · high confidence

Introduce axum-core crate with core body and error types

The \axum-core\ crate is introduced to host core types and traits, allowing library authors to depend on it for \FromRequest\ and \IntoResponse\ implementations without pulling in the full \axum\ framework. This location provides the foundational \Body\ type, which now supports creating bodies of unknown size via \Body::unknown()\ (useful for HEAD requests) and converting streams into data via \Body::from\_stream()\. It also defines the \Error\ type with an \into\_inner()\ method to retrieve the underlying boxed error, and implements \From\<()\>\ for \Body\ to allow empty responses from unit returns. Additionally, internal macros for rejection handling and logging are centralized here.

axum-core/src · high confidence

Introduce axum-extra crate with new extractors, responses, and utilities

The \axum-extra\ crate is introduced to host optional utilities for Axum, organized behind feature flags. This release adds the \Either2\ through \Either7\ types for combining multiple extractors or responses into a single type, a \JsonLines\ extractor and response for newline-delimited JSON streams, and a \Protobuf\ extractor and response for Protocol Buffer messages. It also includes a \TypedHeader\ extractor and response for working with typed headers from the \headers\ crate, and an \option\_layer\ middleware utility that conditionally applies a layer while ensuring the output body type remains \axum::body::Body\.

axum-extra/src · high confidence

Introduction of HandleError layer for custom error handling

Axum now provides a \HandleError\ layer and service adapter that allows users to intercept errors from inner services and convert them into custom HTTP responses. This new component enables developers to define custom error-handling logic via a closure, supporting both simple error-to-response conversion and extractors that can inspect the request context before handling the error, thereby integrating error management directly into the service tower stack.

_axum/src/error\handling · high confidence

Introduction of axum-macros crate with derive macros

The \axum-macros\ crate is introduced, providing procedural macros to simplify request extraction and routing. It adds \\#\[derive(FromRequest)\]\ and \\#\[derive(FromRequestParts)\]\ to automatically generate extractor implementations for custom structs, supporting field-level configuration like \via\ extractors and custom rejections. The \\#\[derive(TypedPath)\]\ macro enables type-safe routing by generating \Display\ and \FromRequestParts\ implementations for structs representing URL patterns. Additionally, \\#\[derive(FromRef)\]\ allows automatic state decomposition, while \\#\[debug\_handler\]\ and \\#\[debug\_middleware\]\ provide compile-time validation of handler signatures, such as checking extractor counts and state type inference.

axum-macros/src · high confidence

New AsyncReadBody for streaming AsyncRead sources

The \axum-extra\ crate now exposes an \AsyncReadBody\ type (behind the \async-read-body\ feature flag) that allows users to convert any \tokio::io::AsyncRead\ implementation, such as a file handle, directly into an HTTP response body. This enables efficient streaming of data from async read sources without requiring manual buffering or conversion to bytes, simplifying the implementation of handlers that serve large files or other stream-based content.

axum-extra/src/body · high confidence

New RequestExt and RequestPartsExt traits for simplified extraction

The \axum-core\ crate now exposes \RequestExt\ and \RequestPartsExt\ traits, providing convenient methods like \extract\, \extract\_with\_state\, and \extract\_parts\ on \Request\ and \Parts\ objects. These additions allow users to apply extractors directly to request instances or parts without manually invoking the \FromRequest\ or \FromRequestParts\ traits, streamlining the process of pulling data from requests in handlers.

_axum-core/src/ext\traits · high confidence

New WebSocket example supporting HTTP/2

Added a new example in the \examples/websockets-http2\ directory that demonstrates how to run WebSocket connections over HTTP/2. The example includes a Rust server (\src/main.rs\) using \axum\ and \axum-server\ with a self-signed TLS certificate, specifically enabling the HTTP/2 CONNECT protocol to support WebSocket upgrades. It also provides the necessary client-side assets (\assets/index.html\ and \assets/script.js\) for testing the connection.

examples/websockets-http2 · high confidence

New WebSocket example with concurrent client support

The \examples/websockets\ location now provides a complete, runnable WebSocket demonstration. It includes a server (\main.rs\) that serves static assets, handles WebSocket upgrades, and manages concurrent send/receive tasks per connection, alongside a Rust-based stress-test client (\client.rs\) that opens multiple simultaneous connections. A browser-based client (\assets/index.html\ and \script.js\) is also included to demonstrate basic WebSocket interaction from a web page.

examples/websockets · high confidence

New \`serve\` API with connection limits and listener extensions

The \axum::serve\ function has been refactored to support generic listeners and IO types, allowing users to apply connection-level constraints and inspect connections before they are handled. Users can now limit the number of concurrent connections using \ListenerExt::limit\_connections\ and inspect or modify incoming IO streams via \ListenerExt::tap\_io\. Additionally, the new \Serve\ builder exposes \connection\_lifetime\_limits\ to bound the maximum age of individual connections, helping to prevent stale connection pools behind load balancers.

axum/src/serve · high confidence

New error-handling example demonstrating custom error conversion and logging

Added a new example in \examples/error-handling\ that demonstrates how to convert application errors into HTTP responses. The example shows how to create a custom JSON extractor (\AppJson\) to handle input validation errors, map third-party library errors (like \time\_library\) to a generic internal server error, and use middleware to log errors without exposing sensitive details to the client. It also illustrates how to integrate with \tower\_http::trace::TraceLayer\ for structured request logging.

examples/error-handling · high confidence

New example demonstrating WebSocket testing strategies

Added a new example in \examples/testing-websockets\ that shows two approaches for testing Axum WebSocket handlers: an integration test that runs the server and connects with a real client, and a unit test that mocks the socket using \Sink\ and \Stream\ traits via channels. This helps users understand how to verify WebSocket logic in their applications.

examples/testing-websockets · high confidence

New example demonstrating axum with hyper's low-level API

Added a new example (\examples/serve-with-hyper\) that shows how to run an axum application using hyper's low-level API directly, rather than relying on higher-level utilities. The example illustrates setting up a TCP listener, converting sockets using \TokioIo\, and serving connections via \hyper::server::conn::auto::Builder\, including a variant that exposes the remote client address via the \ConnectInfo\ extractor.

examples/serve-with-hyper · high confidence

New handler chaining with \`HandlerCallWithExtractors\` and \`or\` fallback

The \axum-extra\ crate now provides a \HandlerCallWithExtractors\ trait and an \Or\ combinator that allows developers to chain multiple handlers together using the \.or()\ method. This feature enables fallback logic where the framework attempts to extract inputs for the first handler; if extraction fails (rejects), it automatically proceeds to the next handler in the chain, and so on, until one succeeds or all fail. This simplifies scenarios like role-based access control or flexible routing where multiple handler signatures might apply to a single route.

axum-extra/src/handler · high confidence

New middleware utilities for request/response mapping and extractor-based validation

The \axum::middleware\ module now includes \from\_extractor\, \from\_fn\, \from\_fn\_with\_state\, \map\_request\, \map\_request\_with\_state\, \map\_response\, and \map\_response\_with\_state\ to create middleware from extractors or async functions, allowing request transformation, response mapping, and validation with optional state access. Additionally, \ResponseAxumBodyLayer\ is provided to map response bodies back to \axum::body::Body\, and \AddExtension\ is exported for adding extensions to requests.

axum/src/middleware · high confidence

New response types for file attachments, streaming, and JSON

axum-extra introduces several new response types to simplify common HTTP patterns. The \Attachment\ type wraps a response body to force a file download via the \Content-Disposition\ header, including safe escaping of filenames to prevent header injection. \FileStream\ enables efficient streaming of large files with support for HTTP range requests. \ErasedJson\ allows returning JSON responses from handlers that do not know the concrete type at compile time, while \InternalServerError\ provides a safe way to return generic 500 errors without exposing internal details. Additionally, \MultipartForm\ allows building multipart/form-data responses, and new \JavaScript\, \Css\, and \Wasm\ response types automatically set the correct content types.

axum-extra/src/response · high confidence

New typed routing and resource helpers in axum-extra

The \axum-extra/src/routing\ module now provides \RouterExt\ with \typed\_get\, \typed\_post\, and other HTTP-method-specific routing methods that infer paths from structs implementing \TypedPath\, enabling compile-time verification of route definitions. It also introduces a \Resource\ helper for defining conventional CRUD routes (index, create, show, edit, update, destroy) and a \vpath!\ macro (on Rust 1.80+) to validate static paths at compile time, including checks for deprecated variable syntax.

axum-extra/src/routing · high confidence

Behavioural changes

Breaking changes to \#\[derive(FromRequest)\] and \#\[from\_request(via)\] behavior

The \\#\[from\_request(via(Extractor))\]\ attribute now uses the extractor's own rejection type instead of \axum::response::Response\, changing how errors are propagated. Additionally, \Option\<T\>\ fields in \\#\[derive(FromRequest)\]\ and \\#\[derive(FromRequestParts)\]\ now rely on \OptionalFromRequest\ / \OptionalFromRequestParts\ traits rather than silently converting all rejections to \None\ via \.ok()\, meaning extractors used with optional fields must implement these new traits to control when \None\ is returned versus an error.

axum-macros · high confidence

Customize extractor error example refactored to demonstrate modern Axum patterns

The customize-extractor-error example has been rewritten to showcase three distinct approaches for customizing extractor rejections: using \axum\_extra::extract::WithRejection\, deriving \FromRequest\ via the \axum-macros\ crate, and manually implementing \FromRequest\. The example now utilizes \JsonRejection::status()\ and \JsonRejection::body\_text()\ for precise error handling, replaces the deprecated \async\_trait\ with native async functions (AFIT/RPITIT), and updates the server setup to use \axum::serve\ instead of \axum::Server\. Additionally, tracing initialization has been simplified using \env!("CARGO\_CRATE\_NAME")\.

examples/customize-extractor-error · high confidence

Enhanced tracing configuration and server startup in the logging example

The tracing-aka-logging example now uses a more realistic setup: it initializes the tracing subscriber with an EnvFilter that explicitly logs axum rejections at the TRACE level, and it customizes the TraceLayer to include the matched route path in spans. Additionally, the example has been updated to use the newer axum::serve API with a TcpListener instead of the deprecated axum::Server, and imports have been adjusted to reflect these changes.

examples/tracing-aka-logging · high confidence

Extractor API overhaul: new extractors and migration to FromRequestParts

The \extract\ module has been significantly restructured. Several new extractors have been added: \NestedPath\ to access the path a route is nested at, \OriginalUri\ to retrieve the full request URI regardless of nesting, and \RawForm\ to extract raw form data or query strings as bytes. The \State\ extractor has been moved to its own module with updated documentation on substates and inheritance. Conversely, several older extractors and utilities have been removed or relocated: \ContentLengthLimit\, \Extension\, \Form\, \TypedHeader\, and \RequestParts\ have been deleted from this location (with \Extension\ and \TypedHeader\ moved to \axum-extra\ or other locations), and \extractor\_middleware\ has been removed. The core extraction trait has shifted from \FromRequest\ (using \RequestParts\) to \FromRequestParts\ (using \http::request::Parts\), affecting \ConnectInfo\, \MatchedPath\, and others. \ConnectInfo\ now supports mocking via \MockConnectInfo\ and uses the \Connected\ trait for stream address extraction.

axum/src/extract · high confidence

Graceful shutdown example now uses axum::serve

The graceful-shutdown example has been updated to use the \axum::serve\ API instead of the previous \Server\ builder. This change simplifies the server setup by removing the need for explicit re-exports and aligns the example with the current Axum serving mechanism, while retaining the graceful shutdown behavior that waits for in-flight requests to complete upon receiving a termination signal.

examples/graceful-shutdown · high confidence

Hello-world example updated to use new Router and serve API

The hello-world example has been updated to reflect recent API changes in the framework. It now uses the \Router::new().route()\ pattern instead of the previous routing DSL, and utilizes the new \axum::serve\ function for starting the server, replacing the older \Server\ re-export. This ensures the example remains compatible with the current library interface.

examples/hello-world · high confidence

Internal refactoring to support type-erased routing and new extraction traits

This change introduces internal infrastructure to support the new \FromRequestParts\ and \OptionalFromRequestParts\ extraction traits, which allow extractors to inspect request metadata (like headers) without consuming the body. The \Extension\ extractor now implements these traits to support optional extraction (\Option\<Extension\<T\>\>\) and acts as a \tower::Layer\ to inject state into request extensions. Additionally, a new \BoxedIntoRoute\ type-erased routing mechanism is added to optimize internal route handling, and the \ServiceExt\ trait is expanded to include a \handle\_error\ method for centralized error handling.

axum/src · high confidence

JWT example updated for Axum 0.8 and jsonwebtoken 10

The JWT example has been updated to align with recent framework changes. It now uses \FromRequestParts\ instead of the deprecated \async\_trait\-based \FromRequest\, and \TypedHeader\ has been moved to the \axum-extra\ crate. The server startup logic now uses \axum::serve\ with a \TcpListener\ instead of \axum::Server\. Additionally, the example now relies on \jsonwebtoken\ version 10, which requires the \exp\ claim to be a valid UTC timestamp (updated from an arbitrary large integer to a specific date in 2033). Tracing initialization has also been modernized to use \EnvFilter\ and \LazyLock\.

examples/jwt · high confidence

Key-value store example adopts Axum 0.7+ APIs and modernized configuration

The key-value store example has been updated to align with recent Axum changes, replacing the deprecated \Extension\ extractor with the type-safe \State\ extractor for accessing shared application state. Request body limiting now uses \DefaultBodyLimit\ and \tower\_http::limit::RequestBodyLimitLayer\ instead of the removed \ContentLengthLimit\, and authentication is handled via \tower\_http::validate\_request::ValidateRequestHeaderLayer\ rather than the deprecated \RequireAuthorizationLayer\. Additionally, the example uses unified route syntax (e.g., \/{key}\), configures tracing via \EnvFilter\, and serves the application using \axum::serve\ with a \TcpListener\ instead of the removed \Server\ re-export.

examples/key-value-store · high confidence

New and updated request extractors in axum-extra

The \axum-extra\ extractors module now includes several new and modified components for handling request data. A new \JsonDeserializer\ extractor enables zero-copy JSON deserialization, allowing users to parse JSON bodies into types with borrowed lifetimes (e.g., \&str\) without allocating owned strings. The \Multipart\ extractor is added to handle \multipart/form-data\ requests, such as file uploads, with runtime enforcement of field exclusivity. Additionally, the \Query\ and \Form\ extractors are introduced (though marked deprecated in favor of the core \axum\ equivalents) to support deserializing query strings and form bodies, with specific rejection types for different HTTP methods. The \Cached\ extractor has been refactored to use \FromRequestParts\ directly on request extensions, simplifying its implementation and removing the need for \async\_trait\. Finally, the \WithRejection\ extractor allows customizing how extraction failures are transformed into responses.

axum-extra/src/extract · high confidence

New request body size limiting and extractor infrastructure in axum-core

The \axum-core/src/extract\ module now includes a \DefaultBodyLimit\ layer that allows you to configure the maximum size of request bodies (defaulting to 2 MB) for extractors like \Bytes\, \String\, \Json\, and \Form\, with the ability to disable or customize this limit per route. This change also introduces the \FromRef\ trait for extracting sub-states, \OptionalFromRequest\ traits for handling optional extractor results, and new \FromRequest\ implementations for \BytesMut\ and \Extensions\, while ensuring that body-limiting is applied consistently via \into\_limited\_body\.

axum-core/src/extract · high confidence

New routing module with method filtering and service composition

The \axum/src/routing\ module has been restructured into distinct components to support method-based routing and service composition. This includes the introduction of \MethodFilter\ for matching HTTP methods (including CONNECT and QUERY), a new \MethodRouter\ for chaining handlers and services by method, and a \Router\ type that uses \Arc\ for efficient cloning. The routing logic now relies on \PathRouter\ for path matching via \matchit\, with dedicated files for handling futures (\future.rs\), making services (\into\_make\_service.rs\), and stripping prefixes for nested routes (\strip\_prefix.rs\).

axum/src/routing · high confidence

OAuth example modernized with typed state, error handling, and updated server setup

The OAuth example has been refactored to use Axum's \State\ extractor instead of \Extension\, centralizing configuration in an \AppState\ struct that implements \FromRef\ for \MemoryStore\ and the OAuth client. Error handling has been improved by replacing \unwrap()\ calls with \anyhow\ context propagation, ensuring graceful failure reporting. The server startup now uses \axum::serve\ with a manually bound \TcpListener\ instead of the deprecated \Server::bind\, and tracing initialization has been updated to use \EnvFilter\ with \CARGO\_CRATE\_NAME\ for better log filtering. Additionally, the example now includes a CSRF token stored in the session and uses \oauth2\ 5 types.

examples/oauth · high confidence

Refactor \#\[derive(FromRequest)\] to support custom via extractors and state inference

The \\#\[derive(FromRequest)\]\ macro has been refactored to allow users to specify a custom extractor via the \via\ attribute, enabling more flexible request extraction logic. Additionally, the macro now supports inferring the state type from field types and attributes, reducing the need for explicit state declarations, while still allowing manual override via the \state\ attribute. This change improves usability and flexibility for users defining custom extractors.

_axum-macros/src/from\request · high confidence

Refactor unix-domain-socket example to use modern axum and hyper APIs

The unix-domain-socket example has been updated to align with current axum and hyper usage patterns. The server setup now uses the new \axum::serve\ function instead of the deprecated \Server::builder\ and custom \Accept\ trait implementations. Client-side code has been refactored to use \hyper::client::conn::http1::handshake\ with \TokioIo\ instead of the legacy \hyper::Client\ builder with custom connectors. Additionally, tracing initialization has been modernized to use \tracing\_subscriber\'s layered API, and the handler now uses inline format arguments.

examples/unix-domain-socket · high confidence

Refactored handler execution into dedicated future and service types

The handler module has been restructured to improve type safety and clarity. A new \future.rs\ module introduces specific future types (\IntoServiceFuture\ and \LayeredFuture\) to handle the asynchronous execution of handlers, separating the response mapping logic from the core handler trait. The \service.rs\ module now explicitly defines \HandlerService\, which implements the \tower::Service\ trait to bridge handlers with the request lifecycle. This change consolidates how handlers are converted into services via \into\_service\ and \with\_state\, ensuring that the underlying future types correctly map handler outputs to \Response\ objects while maintaining compatibility with existing routing and middleware layers.

axum/src/handler · high confidence

Refactored test infrastructure with new helper modules and updated TestClient

The internal test helpers have been reorganized into a dedicated module, introducing a \CountingCloneableState\ utility to track state cloning during tests and a \capture\_tracing\ helper for capturing structured log output. The \TestClient\ implementation has been simplified to use the \serve\ function directly instead of \hyper::Server\, its methods have been made public, and it now supports the \IntoFuture\ trait for more ergonomic async usage. Additionally, the client builder explicitly disables redirects, and the \json\ method now relies on \serde\_core\.

_axum/src/test\helpers · high confidence

Removal of legacy \`App\` and \`RouteBuilder\` routing API

The \src/lib.rs\ file containing the original \App\, \RouteBuilder\, and \Handler\ traits has been deleted. This removes the previous routing API where applications were constructed via \app().at(...).get(...)\, replacing it with the newer \Router\-based approach (likely introduced in other parts of this change set). Users must migrate to the new routing DSL to define routes and handlers.

src · high confidence

Response handling refactored with IntoResponseParts and AppendHeaders

The response module has been restructured to introduce the \IntoResponseParts\ trait and the \AppendHeaders\ helper, while removing the legacy \Headers\ struct. Users can now use \AppendHeaders\ to add multiple headers to a response without overriding existing ones (such as \Set-Cookie\ headers), and the new \IntoResponseParts\ trait allows for more flexible composition of response headers and extensions. The \Headers\ type has been removed in favor of these new mechanisms, and the module now exports \IntoResponse\, \IntoResponseParts\, \ResponseParts\, and \TryIntoHeaderError\ directly.

axum-core/src/response · high confidence

Simplified Redirect API and added NoContent shortcut

The \Redirect\ type now accepts \impl Into\<String\>\ for URIs instead of requiring \Uri\ or \HeaderValue\, removing the need for manual parsing and eliminating potential panics on invalid values. It also implements \IntoResponseParts\, allowing redirects to be combined with bodies in response tuples. A new \NoContent\ struct provides a self-documenting way to return 204 No Content responses, distinct from the unit type's 200 OK behavior. Additionally, \Html\ now accepts any \IntoResponse\ type for its body, and several internal types like \Extension\ and \TypedHeader\ have been reorganized or removed from this module.

axum/src/response · high confidence

Simplified request/response logging middleware and server setup

The print-request-response example now uses a streamlined \middleware::from\_fn\ approach to log request and response bodies, replacing the previous complex Tower layer stack (\HandleErrorLayer\, \AndThenLayer\, \AsyncFilterLayer\). This change simplifies the code by using \http\_body\_util\ for body buffering and \tokio::net::TcpListener\ with \axum::serve\ instead of the older \axum::Server\ API, resulting in cleaner, more idiomatic Rust code for users following this example.

examples/print-request-response · high confidence

Simplified server startup and added integration tests for the templates example

The templates example now uses a cleaner initialization pattern for tracing, leveraging \`env!(

examples/templates · high confidence

TLS example now redirects HTTP to HTTPS

The \tls-rustls\ example now runs a secondary HTTP server on port 7878 that automatically redirects incoming requests to the secure HTTPS server on port 3000. This change improves the security posture of the example by ensuring clients use encrypted connections, and it also updates the logging setup to use \tracing-subscriber\ with environment-based filtering.

examples/tls-rustls · high confidence

Update chat example to use axum 0.8 APIs and modern tracing setup

The chat example has been updated to align with axum 0.8 changes: state is now managed via \with\_state\ and \State\ extractor instead of \AddExtensionLayer\ and \Extension\, and the server is started using \axum::serve\ with a \TcpListener\ instead of \axum::Server::bind\. Additionally, the example now uses \futures\_util\ instead of \futures\, handles WebSocket text messages with \Utf8Bytes\ for type safety, and initializes tracing using \tracing\_subscriber\ with \EnvFilter\ and \env!("CARGO\_CRATE\_NAME")\ for better log filtering.

examples/chat · high confidence

Update http-proxy example to use Hyper 1.0

The http-proxy example has been migrated to Hyper 1.0, replacing the previous axum::Server with a manual TcpListener loop and hyper::server::conn::http1::Builder. This change updates the underlying HTTP/1 connection handling, including the use of TokioIo for stream wrapping and explicit header case preservation, while also simplifying tracing initialization via env! macros.

examples/http-proxy · high confidence

Update multipart form example to use modern Axum patterns and enhanced logging

The multipart form example has been updated to reflect current best practices in the Axum ecosystem. The \ContentLengthLimit\ extractor has been removed in favor of using \DefaultBodyLimit::disable()\ and \tower\_http::limit::RequestBodyLimitLayer\ for configuring request body size limits. Tracing initialization now uses \EnvFilter\ with \env!("CARGO\_CRATE\_NAME")\ for more robust and configurable logging. Additionally, the server startup code now uses \axum::serve\ with a \TcpListener\ instead of the deprecated \axum::Server::bind\. Finally, the form processing logic now extracts and logs the file name and content type for each uploaded field, providing more detailed information in the console output.

examples/multipart-form · high confidence

Update reverse-proxy example to Axum 0.7

The reverse-proxy example has been updated to align with Axum 0.7, replacing the deprecated \Extension\ extractor with \State\ for dependency injection and switching from \axum::Server\ to \axum::serve\ with a \tokio::net::TcpListener\. The HTTP client implementation also migrates from \hyper\ to \hyper\_util\, and the handler now returns a \Result\ with explicit error handling instead of unwrapping.

examples/reverse-proxy · high confidence

Update todos example to use Axum 0.7 API patterns

The todos example has been updated to align with Axum 0.7 changes, replacing the \Extension\ extractor with \State\ for dependency injection and switching route parameters from \:id\ to \{id}\ syntax. The application startup now uses \axum::serve\ with a \TcpListener\ instead of the deprecated \Server::bind\, and the database state is passed via \.with\_state()\ rather than the \AddExtensionLayer\. Additionally, the \todos\_index\ handler now requires the \Query\ extractor explicitly instead of accepting an \Option\, and the \todos\_update\ handler has been adjusted to accept \State\ before \Json\.

examples/todos · high confidence

Update tokio-postgres example to use modern Axum APIs

The tokio-postgres example has been updated to align with current Axum best practices. State management now uses the \State\ extractor and \.with\_state()\ method instead of the deprecated \Extension\ layer and \AddExtensionLayer\. Custom extractors have been migrated from the legacy \FromRequest\ trait to the new \FromRequestParts\ trait, allowing direct access to application state. Additionally, the server startup logic now uses \axum::serve\ with a \TcpListener\ instead of \axum::Server\, and tracing initialization has been refactored to use \EnvFilter\ for more flexible log configuration.

examples/tokio-postgres · high confidence

Updated CORS example to use modern tower-http and axum APIs

The CORS example has been updated to align with current library APIs. The \CorsLayer\ configuration now accepts a \HeaderValue\ for the origin instead of the \Origin\ wrapper, and the \allow\_methods\ method now takes a slice instead of a \Vec\. Additionally, the example now uses \axum::serve\ with a \TcpListener\ instead of the deprecated \axum::Server::bind\ pattern, and includes a comment noting that \allow\_headers\ may be required for POST requests with specific content types.

examples/cors · high confidence

Updated low-level-rustls example to use hyper-util and modern TLS APIs

The low-level-rustls example has been refactored to align with current hyper and rustls standards. It now uses \hyper-util\ for connection handling (replacing direct \hyper::server\ usage) and \tokio\_rustls\'s \pki\_types\ for certificate and key loading, simplifying the TLS configuration. The HTTP handler no longer extracts client address information via \ConnectInfo\, instead returning a static response, and logging is configured using \tracing\_subscriber\ with crate-name-based defaults. Asset paths for certificates are now resolved relative to the manifest directory for robustness.

examples/low-level-rustls · high confidence

Validator example enforces a minimum name length of 2 characters and adds integration tests

The validator example now requires the 'name' query parameter to be at least 2 characters long, updating the validation rule from a minimum of 1 character and changing the error message to 'Must be at least 2 characters'. This behavioral change is accompanied by the addition of integration tests that verify the new validation logic, including cases for missing parameters, empty values, short values, and valid inputs. The example also updates its internal implementation to use modern Axum patterns, such as replacing \async\_trait\ with native async functions, using \axum::serve\ instead of \Server::bind\, and simplifying tracing initialization.

examples/validator · high confidence

Versioning example updated to use modern Axum APIs and includes tests

The versioning example now uses the \FromRequestParts\ trait instead of the deprecated \FromRequest\ and \async\_trait\, aligning with current Axum extractor patterns. The handler returns an \Html\ response instead of printing to stdout, and the application setup uses the new \axum::serve\ API with a \TcpListener\. Additionally, inline unit tests have been added to verify correct routing for supported versions (V1) and proper rejection for unsupported versions (V4).

examples/versioning · high confidence

Test coverage

Add form handling example with tests; Add testing example demonstrating in-process and live server testing; Added compile-fail tests for \\#\[debug\_handler\]\ macro; Added compile-fail tests for \\#\[derive(FromRequest)\]\ validation rules; Added compile-time validation tests for TypedPath macro errors; Added comprehensive test coverage for routing behavior; Added test for panic location in overlapping method routes; Added tests for debug\_middleware macro validation; Added tests for the \\#\[derive(FromRef)\]\ macro; Added tests for typed path macro capabilities; Expanded compile-time tests for \\#\[derive(FromRequest)\]\ and \\#\[derive(FromRequestParts)\]\; Expanded test coverage for \\#\[debug\_handler\]\ macro validation.

Dependencies

Axum 0.8.9 release with updated dependencies

This update releases axum 0.8.9, axum-core 0.5.6, and axum-extra 0.12.6, along with axum-macros 0.5.1. The release includes dependency upgrades such as updating the \bytes\ crate to 1.7, \matchit\ to 0.9.2, and \tower-http\ to 0.6.8. Example projects have also been updated to use newer versions of their respective dependencies, including \askama\ 0.16, \diesel-async\ 0.9, and \jsonwebtoken\ 11.

(dependencies) · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 46 → 50 (+3.7)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.

Lenses

  • Code Health 96 → 95 (-1.0)
  • Architecture 95 → 95 (+0.1)
  • Maturity 53 → 62 (+8.8)
  • Readiness 61 → 70 (+8.3)
  • Security 25 → 25 (+0.6)
  • Performance 86 → 86 (+0.0)

Resolved (31)

  • Boundary-crossing change coupling: form.rs ↔ query.rs (axum-extra/src/extract/form.rs)
  • Change coupling: private.rs ↔ signed.rs (axum-extra/src/extract/cookie/private.rs)
  • Duplicated block (20 lines × 2) (axum-extra/src/extract/multipart.rs)
  • Duplicated block (8–11 lines × 2) (axum-macros/src/from_request/attr.rs)
  • Duplicated block (9 lines × 2) (axum-macros/src/from_request/mod.rs)
  • Leaked secret: private-key (examples/low-level-native-tls/self_signed_certs/key.pem)
  • Leaked secret: private-key (examples/low-level-openssl/self_signed_certs/key.pem)
  • Leaked secret: private-key (examples/low-level-rustls/self_signed_certs/key.pem)
  • Leaked secret: private-key (examples/tls-graceful-shutdown/self_signed_certs/key.pem)
  • Leaked secret: private-key (examples/tls-rustls/self_signed_certs/key.pem)
  • Leaked secret: private-key (examples/websockets-http2/self_signed_certs/key.pem)
  • Medium advisory (unsound): RUSTSEC-2026-0097 (Cargo.lock)
  • Medium advisory (unsound): RUSTSEC-2026-0386 (Cargo.lock)
  • Off-boarding risk: anonymized user #1
  • Orphaned file (axum-core/src/response/mod.rs)
  • Orphaned file (axum-extra/src/json_lines.rs)
  • Orphaned file (axum-extra/src/response/erased_json.rs)
  • Orphaned file (axum/src/handler/service.rs)
  • Orphaned file (axum/src/middleware/from_fn.rs)
  • Orphaned file (axum/src/response/mod.rs)
  • …and 11 more

New (77)

  • Duplicated block (10 lines × 3) (axum-macros/src/typed_path.rs)
  • Duplicated block (11 lines × 2) (axum-macros/src/from_request/mod.rs)
  • Duplicated block (11–12 lines × 2) (axum-macros/src/from_request/mod.rs)
  • Duplicated block (12 lines × 2) (axum-macros/src/from_request/mod.rs)
  • Duplicated block (14 lines × 2) (axum-macros/src/from_request/mod.rs)
  • Duplicated block (20 lines × 2) (axum-extra/src/extract/multipart.rs)
  • Duplicated block (6 lines × 2) (axum-extra/src/extract/query.rs)
  • Duplicated block (7 lines × 2) (axum-macros/src/from_request/mod.rs)
  • Duplicated block (8 lines × 2) (axum-macros/src/from_request/mod.rs)
  • Duplicated block (9 lines × 2) (axum-macros/src/from_request/mod.rs)
  • Edited copies of one member (3 members, 7+ corresponding lines) (axum/src/middleware/from_fn.rs)
  • Edited copies of one member (3 members, 7+ corresponding lines) (axum/src/middleware/from_fn.rs)
  • Edited copies of one member (3 members, 8+ corresponding lines) (axum/src/middleware/from_fn.rs)
  • Edited copies of one member (4 members, 15+ corresponding lines) (axum-extra/src/extract/multipart.rs)
  • Edited copies of one member (4 members, 16+ corresponding lines) (axum-macros/src/debug_handler.rs)
  • Edited copy of a member (10 corresponding lines) (axum-extra/src/extract/query.rs)
  • Edited copy of a member (10 corresponding lines) (axum-extra/src/response/erased_json.rs)
  • Edited copy of a member (10 corresponding lines) (axum/src/extract/ws.rs)
  • Edited copy of a member (13 corresponding lines) (axum-extra/src/extract/multipart.rs)
  • Edited copy of a member (13 corresponding lines) (axum/src/extract/path/mod.rs)
  • …and 57 more

Changes since last survey

  • 16 commits — 15 feature/other, 1 fixes

By area

  • axum-extra/src — 4 commits
  • axum-extra/CHANGELOG.md — 3 commits
  • axum/src — 3 commits
  • .github/workflows — 2 commits
  • axum-core/README.md — 2 commits
  • (root) — 1 commit
  • axum-macros/CHANGELOG.md — 1 commit

Notable commits

  • fix: axum-macros: fix debug_handler treating Parts as a body extractor (#3967)
  • change: axum(serve): Set TCP_NODELAY on accepted TCP connections (#3984)
  • change: axum,axum-extra: speed up Json response generation by using Vec instead of Bytes (#3982)
  • change: axum-extra: don't leave a trailing ? in TypedPath query params (#3968)
  • change: axum-extra: keep non-ASCII filenames in Attachment (#3978)
  • change: axum-extra: only track the error path once deserialization has failed (#3990)
  • change: axum-extra: read in 64 KiB chunks in AsyncReadBody (#3991)
  • change: axum-extra: reject byte-range specs with leading plus sign or whitespace (#3994)
  • change: axum: Finalize a served Router once instead of per connection (#3936)
  • change: axum: Reduce async 'stack' size of Next::run (#3998)
  • change: chore(deps): bump crate-ci/typos from 1.51.1 to 1.52.0 (#3996)
  • change: chore(deps): bump release-plz/action from 0.5.139 to 0.5.148 (#3997)
  • change: chore(deps): resolve RustSec advisories in lockfiles (#3977)
  • change: docs: fix dead CI badge links and http::Request link (#3995)
  • change: docs: point README MSRV sections at rust-version (#3989)
  • change: feat(axum-extra)!: make Range responses RFC-compliant for FileStream and multipart (#3818)

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

tokio-rs/axum was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 14 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 3ebdbe686c3d828dd8daff49c1a0d1516f102a02 — the exact code this score is about.
  • Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.65+preprod-36d4cd83012f.