axum-impl-middleware

Installation
SKILL.md

axum-impl-middleware

Overview

Axum has no middleware system of its own. It integrates the Tower ecosystem (tower::Service plus tower::Layer). The axum::middleware module supplies ergonomic helpers so middleware can be a plain async fn instead of a hand-written Service.

Three implementation strategies, narrowest first:

  • map_request / map_response: a pure one-way transform (add a header, normalise a field). No Next, cannot short-circuit, cannot see both sides.
  • from_fn / from_fn_with_state: an async fn that receives Next and runs code before AND after the handler, and may short-circuit it.
  • A hand-written tower::Layer plus tower::Service: required only when the middleware must be configurable or published as a crate.
Installs
4
First Seen
Aug 13, 2026
axum-impl-middleware — impertio-studio/axum-claude-skill-package