Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
zhanghandong avatar

Domain Web

  • 665 installs
  • 1.3k repo stars
  • Updated May 24, 2026
  • zhanghandong/rust-skills

This is a copy of domain-web by actionbook - installs and ranking accrue to the original listing.

domain-web is a Rust layer-3 domain skill that enforces web service design rules for async handlers, Arc state, extractors, and tower tracing for developers building HTTP, REST, GraphQL, or WebSocket APIs in Rust.

About

domain-web is a Layer 3 domain-constraints skill in the zhanghandong/rust-skills stack for Rust web services, triggered on `**/Cargo.toml` paths. It maps domain rules—stateless HTTP, concurrency, middleware ordering, authentication—to Rust-specific design choices using axum, actix, warp, rocket, tower, hyper, and reqwest patterns. Developers reach for domain-web when designing handlers, extractors, Arc-backed shared state, JWT/session auth, CORS, rate limiting, and tower tracing middleware. The skill keeps web APIs stateless, concurrent, and testable by pushing globals into extractors and structured middleware stacks.

  • Maps domain rules to Rust design: stateless HTTP → extractors, concurrency → async Send + Sync
  • Critical rule: web handlers must not block; CPU work via spawn_blocking
  • Shared state guidance: Arc<T> and Arc<RwLock<T>> for thread-safe handler state
  • Request lifecycle: resources scoped to request duration via extractors and ownership
  • Observability pattern: tracing integrated with tower layers

Domain Web by the numbers

  • 665 all-time installs (skills.sh)
  • +8 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/zhanghandong/rust-skills --skill domain-web

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs665
repo stars1.3k
Security audit3 / 3 scanners passed
Last updatedMay 24, 2026
Repositoryzhanghandong/rust-skills

How do you structure async Rust web API handlers?

Apply Rust web domain rules—async handlers, Arc state, extractors, and tower tracing—when designing HTTP, REST, GraphQL, or WebSocket services.

Who is it for?

Rust developers building axum, actix, or tower-based HTTP, REST, GraphQL, or WebSocket services who need domain-level architectural constraints.

Skip if: Developers writing CLI tools, embedded firmware, or frontend-only code with no Rust web server in the project.

When should I use this skill?

The user builds Rust web servers, APIs, middleware, auth, or WebSocket services and `Cargo.toml` is present in the workspace.

What you get

Stateless Rust handlers, Arc-managed shared state, extractor-based dependencies, and tower-traced middleware stacks.

  • Handler and extractor design
  • Middleware and tracing setup
  • Auth and routing patterns

Files

SKILL.mdMarkdownGitHub ↗

Web Domain

Layer 3: Domain Constraints

Domain Constraints → Design Implications

Domain RuleDesign ConstraintRust Implication
Stateless HTTPNo request-local globalsState in extractors
ConcurrencyHandle many connectionsAsync, Send + Sync
Latency SLAFast responseEfficient ownership
SecurityInput validationType-safe extractors
ObservabilityRequest tracingtracing + tower layers

---

Critical Constraints

Async by Default

RULE: Web handlers must not block
WHY: Block one task = block many requests
RUST: async/await, spawn_blocking for CPU work

State Management

RULE: Shared state must be thread-safe
WHY: Handlers run on any thread
RUST: Arc<T>, Arc<RwLock<T>> for mutable

Request Lifecycle

RULE: Resources live only for request duration
WHY: Memory management, no leaks
RUST: Extractors, proper ownership

---

Trace Down ↓

From constraints to design (Layer 2):

"Need shared application state"
    ↓ m07-concurrency: Use Arc for thread-safe sharing
    ↓ m02-resource: Arc<RwLock<T>> for mutable state

"Need request validation"
    ↓ m05-type-driven: Validated extractors
    ↓ m06-error-handling: IntoResponse for errors

"Need middleware stack"
    ↓ m12-lifecycle: Tower layers
    ↓ m04-zero-cost: Trait-based composition

---

Framework Comparison

FrameworkStyleBest For
axumFunctional, towerModern APIs
actix-webActor-basedHigh performance
warpFilter compositionComposable APIs
rocketMacro-drivenRapid development

Key Crates

PurposeCrate
HTTP serveraxum, actix-web
HTTP clientreqwest
JSONserde_json
Auth/JWTjsonwebtoken
Sessiontower-sessions
Databasesqlx, diesel
Middlewaretower

Design Patterns

PatternPurposeImplementation
ExtractorsRequest parsingState(db), Json(payload)
Error responseUnified errorsimpl IntoResponse
MiddlewareCross-cuttingTower layers
Shared stateApp configArc<AppState>

Code Pattern: Axum Handler

async fn handler(
    State(db): State<Arc<DbPool>>,
    Json(payload): Json<CreateUser>,
) -> Result<Json<User>, AppError> {
    let user = db.create_user(&payload).await?;
    Ok(Json(user))
}

// Error handling
impl IntoResponse for AppError {
    fn into_response(self) -> Response {
        let (status, message) = match self {
            Self::NotFound => (StatusCode::NOT_FOUND, "Not found"),
            Self::Internal(_) => (StatusCode::INTERNAL_SERVER_ERROR, "Internal error"),
        };
        (status, Json(json!({"error": message}))).into_response()
    }
}

---

Common Mistakes

MistakeDomain ViolationFix
Blocking in handlerLatency spikespawn_blocking
Rc in stateNot Send + SyncUse Arc
No validationSecurity riskType-safe extractors
No error responseBad UXIntoResponse impl

---

Trace to Layer 1

ConstraintLayer 2 PatternLayer 1 Implementation
Async handlersAsync/awaittokio runtime
Thread-safe stateShared stateArc<T>, Arc<RwLock<T>>
Request lifecycleExtractorsOwnership via From<Request>
MiddlewareTower layersTrait-based composition

---

Related Skills

WhenSee
Async patternsm07-concurrency
State managementm02-resource
Error handlingm06-error-handling
Middleware designm12-lifecycle

Related skills

How it compares

Choose domain-web over generic Rust style guides when you need web-specific domain constraints tied to axum/tower handler and middleware architecture.

FAQ

How does domain-web handle shared state in Rust web apps?

domain-web enforces stateless HTTP by avoiding request-local globals and placing shared data in Arc-backed state passed through extractors, matching axum and tower handler design for concurrent Rust APIs.

Which Rust web frameworks does domain-web cover?

domain-web addresses axum, actix, warp, rocket, tower, hyper, and reqwest patterns for HTTP, REST, GraphQL, WebSocket, middleware, authentication, CORS, and rate limiting in `Cargo.toml` projects.

Is Domain Web safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.