Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Axum Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-axum-knowledge-patch)
---
name: axum-knowledge-patch
description: Axum
version: "0.8.0"
license: MIT
metadata:
author: Nevaberry
---
# Axum compatibility guidance
Load this skill when migrating Axum handlers, routing, extractors, responses,
or streaming code, or adjusting axum-extra and axum-core integrations.
Use the topic references for details and examples; unreleased changes are
explicitly labeled where they appear.
## Reference index
| Reference | Topics |
| --- | --- |
| [Dependency and release compatibility](references/dependency-and-release-compatibility.md) | Rust requirements, yanked dependencies, Cargo features, Protobuf, derive compatibility |
| [Extractors and request bodies](references/extractors-and-request-bodies.md) | Optional extraction, paths, Host, multipart, body limits, rejection diagnostics |
| [Responses and middleware](references/responses-and-middleware.md) | Status and body size, response parts, middleware bodies, redirects, downloads |
| [Routing and serving](references/routing-and-serving.md) | Handler bounds, listeners, CONNECT, typed routing, trailing-slash redirects |
| [WebSockets and streaming](references/websockets-and-streaming.md) | Close frames, HTTP/2 upgrades, subprotocols, SSE, streaming JSON |
## Breaking changes and deprecations
### Stored handlers and services require Sync
`Router` and `MethodRouter` require `Sync` for the handlers and Tower
services they store. When migrating a closure handler, check that its
captured values are `Sync`.
### Optional extractors must opt in
`Option<T>` is an extractor only if `T` implements
`OptionalFromRequestParts` or `OptionalFromRequest`. For optional
authentication, an implementation can return `Ok(None)` for absent
credentials and a rejection for invalid credentials or a database error;
Axum propagates that rejection to the client.
### Tuple path extraction needs the exact capture count
`Path<(A, B)>` and tuple-struct extractors require the number of captured
parameters to equal the tuple length. Three captures reject `Path<(A, B)>`
even when the first two values deserialize successfully.
### Host migration and extractor removals
Add the `axum-extra` dependency and import `axum_extra::extract::Host` to
keep using the `Host` extractor after its move out of Axum.
**Unreleased — axum-extra.** The next release removes `Host`, `Scheme`,
`OptionalPath`, `HostRejection`, and its `FailedToResolveHost` variant.
`Host` and `Scheme` were deprecated in axum-extra 0.12.4, and
`OptionalPath` was deprecated in axum-extra 0.10.0.
### Configure accepted TCP streams through the listener
`axum::serve` is generic over the listener and its I/O type.
`Serve::tcp_nodelay` and `WithGracefulShutdown::tcp_nodelay` were removed;
use `axum::serve::ListenerExt` to configure accepted TCP streams before
serving them.
### Send explicit WebSocket close frames
The inherent `WebSocket::close` method was removed. Send
`socket.send(Message::Close(None)).await?`, or pass a `CloseFrame` with a
code and reason in `Some`.
### Select axum-extra utility features explicitly
In axum-extra 0.12, `Cached`, `OptionalPath`, and `WithRejection` require
`cached`, `optional-path`, and `with-rejection`, respectively. Handler,
middleware, and routing utilities require `handler`, `middleware`, and
`routing`. Remove the deleted `async-stream` feature when upgrading.
From axum-extra 0.12.3, `typed-routing` also enables `routing`, so users
of typed routing can omit a separate `routing` feature entry.
### Adjust middleware response-body bounds
In axum-extra 0.12, services wrapped with `option_layer` return responses
with body type `axum::body::Body`. Update bounds that still expect the
original response body type.
### Use brace-style validated paths
From axum-extra 0.12.6, `vpath!` rejects legacy `:var` and `*var` captures
at compile time. Use brace-style captures such as `vpath!("/users/{id}")`.
## Common extraction and response checks
### Check optional built-in extractor availability
Stable Axum 0.8.0 only supports `Query<T>` as a required extractor, and
`Option<Path<T>>` can reject malformed captures. `Option<Json<T>>` and
`Option<Extension<T>>` start in Axum 0.8.3; `Option<Multipart>` starts in
Axum 0.8.5.
### Set body limits before buffering
From axum-core 0.5.3, a custom extractor can call `DefaultBodyLimit::apply`
on the mutable request before passing it to a buffering extractor.
From axum-core 0.4.4, `DefaultBodyLimit::max` and
`DefaultBodyLimit::disable` can be used in a const context.
From axum-extra 0.12.5, `JsonLines` enforces Axum's default request body
limit. Configure `DefaultBodyLimit` for routes accepting larger
newline-delimited JSON streams.
### Finish multipart fields before advancing
With axum-extra's `Multipart`, finish processing or drop the current field
before calling `next_field()` again; exclusivity is checked at runtime.
From axum-extra 0.10.0, enable `multipart` to use
`axum_extra::extract::Multipart`.
### Inspect parse failures and JSON trailing data
`Query` and `Form` use `serde_path_to_error`; parse rejections can include
the path of the field that failed. For named path parameters, match
`ErrorKind::DeserializeError { key, value, message }` on
`FailedToDeserializePathParams::kind()` for the name, value, and message.
From Axum 0.8.5, `Json<T>` rejects non-whitespace bytes after a valid JSON
document. Send a single document per request body.
### Account for response headers and exact bodies
Axum defers setting `Content-Length` until after middleware runs.
Middleware that adds a body can leave the automatic header unset.
From Axum 0.8.5, constructing a `Redirect` with a location that cannot be
encoded as a header succeeds, but converting it into a response returns
HTTP 500.
From axum-extra 0.12.3, `ErasedJson::pretty` appends a newline to the body;
include it in snapshots and exact body comparisons.
## Routing and streaming quick reference
### Accept HTTP/1.1 and HTTP/2 WebSocket upgrades
Register a `WebSocketUpgrade` handler with
`.route("/ws", axum::routing::any(ws_endpoint))` to accept HTTP/1.1 GET
upgrades and HTTP/2 extended CONNECT on the same path.
### Inspect WebSocket stream state and protocols
From Axum 0.8.5, `WebSocket` implements `FusedStream`; use
`is_terminated()` in a loop that polls several streams to check whether
the stream has ended.
From Axum 0.8.9, inspect offers with
`WebSocketUpgrade::requested_protocols()` and select one with
`set_selected_protocol` before `on_upgrade`.
### Use SSE byte data without requiring tokio
From Axum 0.8.5, SSE data fields can contain arbitrary bytes, including
bytes that cannot be represented in a Rust string. Disabling Axum's
`tokio` feature leaves the `sse` module and `Sse` type available.
### Route CONNECT requests
Use `routing::connect(handler)`, `routing::connect_service(service)`, or
the corresponding `MethodRouter` methods. `MethodFilter::CONNECT` is
available for method filters. Axum 0.8.9 corrects CONNECT endpoint
registration in `MethodRouter`.
`RouterExt::typed_connect` derives a CONNECT route from its `TypedPath`
extractor; it is available in axum-extra 0.9.5 and in the 0.10 line.
## Unreleased APIs and behavior
### Response status through response parts
**Unreleased — axum-core.** An `IntoResponseParts` implementation can read
the status with `ResponseParts::status` and change it through `status_mut`.
### Unknown-size response bodies
**Unreleased — axum-core.** Use `Body::unknown` for a `HEAD` response if
the size of the corresponding `GET` body is unknown.
**Unreleased — axum-core.** Converting `()` to a response produces an
unknown-size body, also affecting standalone `HeaderMap` and `Extensions`
responses. An automatic `Content-Length: 0` is no longer inferred.
### Request bodies with trailers
**Unreleased — axum-core.** `BytesMut` skips non-data frames such as
trailers in custom request bodies, matching `Bytes`.
### Method-specific redirects and typed query routing
**Unreleased — axum-extra.** `RouterExt::route_with_tsr` redirects only
requests whose method the supplied `MethodRouter` handles. Separate GET
and POST registrations on the same path can coexist because redirects
are registered by method.
**Unreleased — axum-extra.** The typed routing API adds
`axum_extra::routing::RouterExt::typed_query`.
### Multipart disposition parameters
**Unreleased — axum-extra.** Multipart `Content-Disposition` parameters
are escaped; field names and filenames containing newlines are rejected.