
Axum Structured Logging and Request IDs With Tracing
Add structured logs and a request id to every Axum request with tower-http TraceLayer, SetRequestIdLayer and tracing spans that carry the id into your code.
Everything you need to level up your coding skills.

Add structured logs and a request id to every Axum request with tower-http TraceLayer, SetRequestIdLayer and tracing spans that carry the id into your code.

Make every Axum handler return Result with one AppError enum that implements IntoResponse, so the question mark works and clients get consistent JSON errors.

Test an Axum API against a real Postgres started by Testcontainers: one container per test binary, one migrated database per test, the leaks and version traps that bite, and measured timings for each isolation strategy.

Tokio has four channel types: mpsc, oneshot, broadcast and watch. Pick by how many senders and receivers you have and whether late messages matter.

Wire Axum 0.8 and SQLx 0.9 into a typed database layer: a pool in state, a db module of compile-time checked queries, one error type, a transaction, offline builds and tests on throwaway databases.

Use an associated type when each implementor has exactly one answer and a generic parameter when a type can implement the trait many ways. The Iterator and From traits show both.

Rust error E0382 means a value was moved and then used again. Here are the five fixes in the order to try them, with the code for each.

Make a dependency optional and expose it as a feature, with dep: syntax to avoid implicit features. Cover cfg gating, testing every combination and the pitfalls of default features.

Server sent events push updates from Axum to the browser over plain HTTP. See Sse, Event, KeepAlive, streams from channels, reconnect with Last-Event-ID and proxy gotchas.

Hash passwords with Argon2id using the argon2 crate: choose parameters, store the PHC string, verify in constant time and rehash when settings change.

Build a chat room over WebSockets in Axum 0.8, using a Tokio broadcast channel to fan messages out, two tasks per socket, size limits and an integration test that drives real clients.

assert, assert_eq, assert_ne, matches and debug_assert, with custom failure messages, float comparison, and what each prints. Includes a helper for readable domain assertions.
We send one email when a new post is published. No spam.