rust-backend-axum

Build Rust backend APIs with Axum 0.7+ and Tower middleware.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/caioniehues/dotfiles --skill rust-backend-axum
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-backend-axum
Source: https://github.com/caioniehues/dotfiles/tree/main/skills/rust-backend-axum
Command: npx skills add https://github.com/caioniehues/dotfiles --skill rust-backend-axum

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Produces production-ready Axum backends with modular routing, state management, extractors, and middleware patterns.

Core Features & Use Cases

  • Modular routers with nested routes and clean state sharing.
  • Extractors & middleware for auth, tracing, and errors.
  • Graceful shutdown and robust error handling strategies.

Quick Start

Use these patterns to assemble a scalable Axum API with layered middleware and clean routing.

Frequently Asked Questions about rust-backend-axum

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a production-grade REST API with Axum and Rust?

Axum is a modular web framework for Rust that handles routing, middleware, and extractors. Use modular router composition with Tower middleware integration, type-safe state management with Arc for shared fields, and proper extractor ordering to build scalable REST services with clean error handling.

What's the right way to structure middleware and authentication in Axum?

Axum middleware uses Tower's layer system to process requests before handlers. Distinguish between route_layer for single routes and layer for all routes; use Extension-based user propagation for auth state and implement IntoResponse for centralized error handling across your API.

How do I manage application state across Axum routes?

Create a Cloneable AppState struct and wrap expensive fields in Arc to share state safely across routes. Pass state through Axum's built-in State extractor, ensuring your AppState derives Clone and implements the patterns Axum expects for thread-safe, concurrent access.

Can I use Axum 0.7+ with nested routes and modular router patterns?

Yes, Axum 0.7+ supports nested routes through Router composition, letting you build modular APIs by combining routers and sharing state cleanly. This approach scales to large applications while keeping route definitions organized and maintainable.

What's the correct order for request extractors in Axum handlers?

Place body-consuming extractors last in your handler signature because they can only run once per request. Order stateless extractors first—Path, Query, Header—followed by State, then Json or other body-based extractors to avoid binding errors.

How do I implement graceful shutdown in an Axum backend?

Graceful shutdown in Axum involves listening for termination signals, stopping new requests, and waiting for in-flight requests to complete before exiting. Implement signal handlers that coordinate with your server's shutdown method to ensure clean resource cleanup.