axum-web-framework
БесплатноБез исполняемых скриптовНе проверенComplete guide for Axum web framework including routing, extractors, middleware, state management, error handling, and production deployment
Об этом скилле
Axum Web Framework
A comprehensive skill for building production-ready web applications and APIs using Axum, the ergonomic and modular Rust web framework built on Tokio and Tower. Master routing, extractors, middleware, state management, error handling, and deployment patterns.
When to Use This Skill
Use this skill when:
- Building REST APIs with Rust and async/await
- Creating high-performance web services with type safety
- Developing microservices with Tokio ecosystem integration
- Implementing WebSocket servers or Server-Sent Events (SSE)
- Building GraphQL APIs with Rust backend
- Creating middleware-heavy applications requiring Tower integration
- Developing production-ready web applications requiring robust error handling
- Building systems requiring fine-grained control over HTTP request/response handling
- Implementing authentication, authorization, and security middleware
- Creating real-time web applications with async Rust
- Developing APIs requiring request validation and transformation
- Building web services with complex routing and nested routers
- Implementing rate limiting, timeout, and backpressure handling
- Creating web applications requiring custom extractors and response types
Core Concepts
Axum Architecture Philosophy
Axum is built on three fundamental pillars:
- Tower Services: Everything in Axum is built on Tower's
Servicetrait, providing composability and middleware integration - Type-Safe Extractors: Request data extraction is compile-time checked, eliminating runtime parsing errors
- Minimal Boilerplate: Ergonomic APIs that reduce ceremony while maintaining explicitness
The Router
The Router is the central building block in Axum. It maps HTTP requests to handlers based on path and method.
Key Properties:
- Routes are matched in the order they're defined
- Routers can be nested for modular organization
- Middleware can be applied at router, route, or method level
- Generic over state type for flexible state management
- Implements Tower's
Servicetrait for composability
Router Creation:
use axum::{Router, routing::get};
let app = Router::new()
.route("/", get(handler))
.route("/users/:id", get(get_user))
.route("/posts", get(list_posts).post(create_post));
Handlers
Handlers are async functions that process requests and return responses. Axum supports multiple handler signatures through its powerful type system.
Handler Requirements:
- Must be async functions
- Can extract data from requests using extractors
- Must return types implementing
IntoResponse - Can have up to 16 parameters (all must be extractors)
Common Handler Patterns:
// Simple handler
async fn handler() -> &'static str {
"Hello, World!"
}
// Handler with path parameter
async fn get_user(Path(user_id): Path<u32>) -> String {
format!("User ID: {}", user_id)
}
// Handler with multiple extractors
async fn create_user(
State(state): State<AppState>,
Json(payload): Json<CreateUser>,
) -> Result<Json<User>, StatusCode> {
// Implementation
}
Extractors
Extractors are types that implement FromRequest or FromRequestParts, allowing type-safe extraction of data from requests.
Built-in Extractors:
- Path - Extract path parameters
- Query - Extract query string parameters
- Json - Parse JSON request body
- Form - Parse form-encoded request body
- State - Access shared application state
- Extension - Access request extensions
- Headers - Access request headers
- Method - Get HTTP method
- Uri - Get request URI
- Request - Get full request
- Bytes - Raw request body as bytes
- String - Request body as UTF-8 string
- Multipart - Handle multipart/form-data
Extractor Ordering:
- Extractors that consume the request body must come last
- Multiple body extractors in one handler will cause compilation errors
Stateand other non-body extractors can be in any order
Responses
Any type implementing IntoResponse can be returned from handlers. Axum provides many built-in implementations.
Built-in Response Types:
String,&'static str- Text responsesJson<T>- JSON responsesHtml<String>- HTML responsesStatusCode- Status-only responses(StatusCode, T)- Status with body(Parts, T)- Custom headers with bodyResponse- Full control over responseResult<T, E>- Error handling (where E: IntoResponse)
State Management
Axum uses the State extractor to share data across handlers. State must implement Clone and is typically wrapped in Arc for shared ownership.
State Patterns:
- Simple State:
#[derive(Clone)]
struct AppState {
api_key: String,
}
let app = Router::new()
.route("/", get(handler))
.with_state(AppState {
api_key: "secret".to_string(),
});
- Shared State with Arc:
#[derive(Clone)]
struct AppSta
Установить axum-web-framework в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл axum-web-framework?
Complete guide for Axum web framework including routing, extractors, middleware, state management, error handling, and production deployment
Как установить скилл axum-web-framework?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл axum-web-framework запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic