# Data flow — tokio-rs/axum

> Canonical page: https://codevetter.com/unpack/axum/data-flow

# Data flow — tokio-rs/axum

Scanned commit f8b02f22cf10bee707bda19b58265b9e33677535 (2026-09-30). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

Incoming connections are converted into per-connection services, and incoming HTTP bodies are normalized before routing. Path matching enriches request extensions, method dispatch selects an endpoint, and handler adapters construct typed arguments in sequence. Response conversion provides the common output boundary for successful values and rejections. Durable data, session storage, and file writes are owned by example applications rather than the routing library.
- handle_connection waits for make_service readiness, calls it with IncomingStream, maps Hyper Incoming bodies into axum Body, and wraps the resulting Tower service with TowerToHyperService. — [axum/src/serve/mod.rs#L814-L828](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/axum/src/serve/mod.rs#L814-L828)
- PathRouter preserves OriginalUri when enabled, matches uri.path(), installs MatchedPath and URL parameters, then dispatches the indexed endpoint; a missing path returns the request and state to Router's fallback. — [axum/src/routing/path_router.rs#L280-L325](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/axum/src/routing/path_router.rs#L280-L325) [axum/src/routing/mod.rs#L445-L454](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/axum/src/routing/mod.rs#L445-L454)
- Handler::call splits the request, extracts all preceding arguments from mutable Parts, reconstructs the request for the last extractor, and returns immediately on any rejection before invoking the handler. — [axum/src/handler/mod.rs#L227-L255](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/axum/src/handler/mod.rs#L227-L255)
- Json extraction validates content type, delegates buffering to Bytes::from_request, deserializes with serde_path_to_error, and calls deserializer.end() to reject trailing data. — [axum/src/json.rs#L99-L113](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/axum/src/json.rs#L99-L113) [axum/src/json.rs#L164-L193](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/axum/src/json.rs#L164-L193) [axum-core/src/extract/request_parts.rs#L101-L115](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/axum-core/src/extract/request_parts.rs#L101-L115)
- State<InnerState> derives application substates through FromRef<OuterState>; Router::with_state distributes supplied state to its path router and catch-all fallback. — [axum/src/extract/state.rs#L303-L315](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/axum/src/extract/state.rs#L303-L315) [axum/src/routing/mod.rs#L436-L442](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/axum/src/routing/mod.rs#L436-L442)
- The key-value example transforms a path capture and body bytes into a HashMap insertion under a write lock; reads clone stored Bytes under a read lock and return 404 when absent. — [examples/key-value-store/src/main.rs#L84-L105](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/examples/key-value-store/src/main.rs#L84-L105)
- Diesel create_user deserializes NewUser, acquires a pooled connection, inserts values inside interact, retrieves the returned User, and serializes it as Json; the migration defines the corresponding users table. — [examples/diesel-postgres/src/main.rs#L45-L50](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/examples/diesel-postgres/src/main.rs#L45-L50) [examples/diesel-postgres/src/main.rs#L92-L107](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/examples/diesel-postgres/src/main.rs#L92-L107) [examples/diesel-postgres/migrations/2023-03-14-180127_add_users/up.sql#L2-L6](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/examples/diesel-postgres/migrations/2023-03-14-180127_add_users/up.sql#L2-L6)
- PrivateCookieJar obtains a key from state, retains only successfully decrypted request cookies, and writes jar changes into response headers through IntoResponseParts. — [axum-extra/src/extract/cookie/private.rs#L125-L164](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/axum-extra/src/extract/cookie/private.rs#L125-L164) [axum-extra/src/extract/cookie/private.rs#L273-L284](https://github.com/tokio-rs/axum/blob/f8b02f22cf10bee707bda19b58265b9e33677535/axum-extra/src/extract/cookie/private.rs#L273-L284)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
