warp
БесплатноБез исполняемых скриптовНе проверенWarp Rust web framework using filters. Covers routing, filters, rejection, WebSocket, and TLS. Use for composable, type-safe Rust APIs. USE WHEN: user…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
Warp Core Knowledge
Deep Knowledge: Use
mcp__documentation__fetch_docswith technology:warpfor comprehensive documentation.
Basic Setup
# Cargo.toml
[dependencies]
warp = "0.3"
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
use warp::Filter;
#[tokio::main]
async fn main() {
let hello = warp::path::end()
.map(|| "Hello, World!");
warp::serve(hello)
.run(([127, 0, 0, 1], 8080))
.await;
}
Filters
Path Filters
use warp::Filter;
// Static path
let index = warp::path::end()
.map(|| "Index");
// Path segment
let users = warp::path("users")
.and(warp::path::end())
.map(|| "Users list");
// Path parameter
let user = warp::path("users")
.and(warp::path::param::<u32>())
.and(warp::path::end())
.map(|id: u32| format!("User {}", id));
// Multiple parameters
let post = warp::path("users")
.and(warp::path::param::<u32>())
.and(warp::path("posts"))
.and(warp::path::param::<u32>())
.and(warp::path::end())
.map(|user_id: u32, post_id: u32| {
format!("User {} Post {}", user_id, post_id)
});
Method Filters
let get_users = warp::get()
.and(warp::path("users"))
.and(warp::path::end())
.map(|| "Get users");
let create_user = warp::post()
.and(warp::path("users"))
.and(warp::path::end())
.map(|| "Create user");
let update_user = warp::put()
.and(warp::path("users"))
.and(warp::path::param::<u32>())
.and(warp::path::end())
.map(|id: u32| format!("Update user {}", id));
let delete_user = warp::delete()
.and(warp::path("users"))
.and(warp::path::param::<u32>())
.and(warp::path::end())
.map(|id: u32| format!("Delete user {}", id));
// Combine routes
let routes = get_users
.or(create_user)
.or(update_user)
.or(delete_user);
Body Filters
use serde::{Deserialize, Serialize};
use warp::Filter;
#[derive(Deserialize, Serialize)]
struct CreateUser {
name: String,
email: String,
}
// JSON body
let create_user = warp::post()
.and(warp::path("users"))
.and(warp::body::json::<CreateUser>())
.map(|user: CreateUser| {
warp::reply::json(&user)
});
// With size limit
let create_user_limited = warp::post()
.and(warp::path("users"))
.and(warp::body::content_length_limit(1024 * 16))
.and(warp::body::json::<CreateUser>())
.map(|user: CreateUser| {
warp::reply::json(&user)
});
Query Filters
#[derive(Deserialize)]
struct Pagination {
page: Option<u32>,
per_page: Option<u32>,
}
let list_users = warp::get()
.and(warp::path("users"))
.and(warp::query::<Pagination>())
.map(|pagination: Pagination| {
let page = pagination.page.unwrap_or(1);
format!("Page {}", page)
});
Header Filters
let with_auth = warp::header::<String>("authorization")
.map(|auth: String| format!("Auth: {}", auth));
// Optional header
let with_optional_header = warp::header::optional::<String>("x-custom")
.map(|custom: Option<String>| {
custom.unwrap_or_else(|| "default".to_string())
});
Handlers
Async Handlers
async fn list_users_handler() -> Result<impl warp::Reply, warp::Rejection> {
let users = fetch_users().await;
Ok(warp::reply::json(&users))
}
let list_users = warp::get()
.and(warp::path("users"))
.and_then(list_users_handler);
With State
use std::sync::Arc;
use tokio::sync::Mutex;
struct AppState {
db_pool: PgPool,
counter: Mutex<u32>,
}
fn with_state(
state: Arc<AppState>,
) -> impl Filter<Extract = (Arc<AppState>,), Error = std::convert::Infallible> + Clone {
warp::any().map(move || state.clone())
}
async fn get_count(state: Arc<AppState>) -> Result<impl warp::Reply, warp::Rejection> {
let count = state.counter.lock().await;
Ok(warp::reply::json(&serde_json::json!({ "count": *count })))
}
#[tokio::main]
async fn main() {
let state = Arc::new(AppState {
db_pool: create_pool().await,
counter: Mutex::new(0),
});
let count_route = warp::get()
.and(warp::path("count"))
.and(with_state(state.clone()))
.and_then(get_count);
warp::serve(count_route)
.run(([127, 0, 0, 1], 8080))
.await;
}
Rejections and Error Handling
Custom Rejection
use warp::reject::Reject;
#[derive(Debug)]
struct NotFound;
impl Reject for NotFound {}
#[derive(Debug)]
struct Unauthorized;
impl Reject for Unauthorized {}
#[derive(Debug)]
struct BadRequest(String);
impl Reject for BadRequest {}
async fn get_user(id: u32) -> Result<impl warp::Reply, warp::Rejection> {
match find_user(id).await {
Some(user) => Ok(warp::reply::json(&user)),
None => Err(warp::reject::custom(NotFound)),
}
}
Rejection Handler
use warp::htt
Установить warp в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobWriteEditFAQ
Что делает скилл warp?
Warp Rust web framework using filters. Covers routing, filters, rejection, WebSocket, and TLS. Use for composable, type-safe Rust APIs. USE WHEN: user mentions "warp", "rust filters", "composable rust api", asks about "warp filters", "warp rejection", "filter composition rust", "rust hyper warp", "warp websocket" DO NOT USE FOR: Axum projects - use `axum` instead, Actix-web projects - use `actix-web` instead, Rocket projects - use `rocket` instead, non-Rust backends
Как установить скилл warp?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл warp запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic