axum-impl-middleware

Official

Add safe Axum middleware without order bugs.

AuthorImpertio-Studio
Version1.0.0
Installs0

System Documentation

What problem does it solve?

This Skill prevents common Axum/Tower middleware wiring mistakes that either fail to compile or silently skip your handler logic. It also avoids subtle routing bugs where an auth gate incorrectly converts missing routes into unauthorized responses.

Core Features & Use Cases

  • Correct middleware helper selection: choose map_request/map_response for one-way transforms and from_fn/from_fn_with_state when you need request+response handling or short-circuiting.
  • Guaranteed from_fn argument ordering: enforces the required shape of [FromRequestParts..., FromRequest, Next] to avoid opaque Handler is not satisfied trait-bound errors.
  • Safe control flow with Next: ensures middleware either calls next.run(request).await or deliberately short-circuits with an IntoResponse, avoiding “handler never runs” incidents.
  • Correct .layer() vs .route_layer() semantics: uses .route_layer() for auth/authz so unmatched paths still return real 404 instead of being masked as 401/403.
  • Layer stacking without reversal confusion: clarifies how Router’s chained .layer() order differs from tower::ServiceBuilder, preventing request/response execution order surprises.

Quick Start

Add middleware to your Axum routes by asking for a from_fn or from_fn_with_state example that uses the correct argument order, short-circuit behavior, and .route_layer() for auth gates on Axum 0.7/0.8.

Dependency Matrix

Required Modules

None required

Components

references

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: axum-impl-middleware
Download link: https://github.com/Impertio-Studio/Axum-Claude-Skill-Package/archive/main.zip#axum-impl-middleware

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.