rs-domain-web
/rs-domain-web
Pomaga budować usługi webowe w Rust: REST, GraphQL, WebSocket, middleware, uwierzytelnianie, JWT, sesje i limity żądań.
- Autor
- bassem-elsodany ↗
- Repozytorium
- rs-skills ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 11.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 2
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 11.11.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Pomaga budować usługi webowe w Rust: REST, GraphQL, WebSocket, middleware, uwierzytelnianie, JWT, sesje i limity żądań.
Oryginalny opis (EN)
Use when building web services. Keywords: web server, HTTP, REST API, GraphQL, WebSocket, axum, actix, warp, rocket, tower, hyper, reqwest, middleware, router, handler, extractor, state management, authentication, authorization, JWT, session, cookie, CORS, rate limiting
Jak działa
- Domain Constraints → Design Implications
- Critical Constraints
- Trace Down ↓
- Framework Comparison
- Key Crates
- Design Patterns
- Code Pattern: Axum Handler
- Common Mistakes
- Trace to Layer 1
- Related Skills
Podgląd SKILL.md
---
name: rs-domain-web
description: "Use when building web services. Keywords: web server, HTTP, REST API, GraphQL, WebSocket, axum, actix, warp, rocket, tower, hyper, reqwest, middleware, router, handler, extractor, state management, authentication, authorization, JWT, session, cookie, CORS, rate limiting"
user-invocable: false
---
# Web Domain
> **Layer 3: Domain Constraints**
## Domain Constraints → Design Implications
| Domain Rule | Design Constraint | Rust Implication |
|-------------|-------------------|------------------|
| Stateless HTTP | No request-local globals | State in extractors |
| Concurrency | Handle many connections | Async, Send + Sync |
| Latency SLA | Fast response | Efficient ownership |
| Security | Input validation | Type-safe extractors |
| Observability | Request tracing | tracing + 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"
↓ rs-concurrency: Use Arc for thread-safe sharing
↓ rs-resource: Arc<RwLock<T>> for mutable state
"Need request validation"
↓ rs-type-driven: Validated extractors
↓ rs-error-handling: IntoResponse for errors
"Need middleware stack"
↓ rs-lifecycle: Tower layers
↓ rs-traits: Trait-based composition
```
---
## Framework Comparison
| Framework | Style | Best For |
|-----------|-------|----------|
| axum | Functional, tower | Modern APIs |
| actix-web | Actor-based | High performance |
| warp | Filter composition | Composable APIs |
| rocket | Macro-driven | Rapid development |
## Key Crates
| Purpose | Crate |
|---------|-------|
| HTTP server | axum, actix-web |
| HTTP client | reqwest |
| JSON | serde_json |
| Auth/JWT | jsonwebtoken |
| Session | tower-sessions |
| Database | sqlx, diesel |
| Middleware | tower |
## Design Patterns
| Pattern | Purpose | Implementation |
|---------|---------|----------------|
| Extractors | Request parsing | `State(db)`, `Json(payload)` |
| Error response | Unified errors | `impl IntoResponse` |
| Middleware | Cross-cutting | Tower layers |
| Shared state | App config | `Arc<AppState>` |
## Code Pattern: Axum Handler
```rust
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
| Mistake | Domain Violation | Fix |
|---------|-----------------|-----|
| Blocking in handler | Latency spike | spawn_blocking |
| Rc in state | Not Send + Sync | Use Arc |
| No validation | Security risk | Type-safe extractors |
| No error response | Bad UX | IntoResponse impl |
---
## Trace to Layer 1
| Constraint | Layer 2 Pattern | Layer 1 Implementation |
|------------|-----------------|------------------------|
| Async handlers | Async/await | tokio runtime |
| Thread-safe state | Shared state | Arc<T>, Arc<RwLock<T>> |
| Request lifecycle | Extractors | Ownership via From<Request> |
| Middleware | Tower layers | Trait-based composition |
---
## Related Skills
| When | See |
|------|-----|
| Async patterns | rs-concurrency |
| State management | rs-resource |
| Error handling | rs-error-handling |
| Middleware design | rs-lifecycle |
| Middleware stack order, layers, rate limiting (`guides/middleware.md`) | this skill → guides/middleware.md |
| JWT/OAuth/sessions/API keys | rs-domain-auth |
| Authorisation decisions | rs-domain-policy |
| Databases and caches | rs-domain-data |
Pliki w paczce (2)
- SKILL.md 4 KB
- guides/middleware.md 4 KB
Wersje
W bazie nie ma innych skilli o nazwie rs-domain-web.
Migawka bazy z 13.11.2026 · wersja paczki 7651cf580104 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Podobne skille
- 100actix-web
Obejmuje framework Actix-web dla Rust: routing, extractory, middleware, zarządzanie stanem i WebSocket w wydajnych API. - 100axum
Obsługuje framework webowy Axum od Tokio w Rust: routing, handlery, extractory, middleware i stan, do ergonomicznych asynchronicznych API, także z WebSocketami i tower. - 100actix-web
Pomaga budować REST API w Rust na Actix Web: handlery, middleware, obsługa błędów przez ResponseError, współdzielona pula bazy danych i testy usługi. - 100axum
Buduje API HTTP i usługi webowe w Rust z Axum: trasy, extractory, handlery JSON, współdzielony stan, middleware, błędy, WebSockety, graceful shutdown, testy i migracja kodu 0.6 i 0.7 do 0.8. - 100axum
Wspiera pracę z Axum: routing, extractory, middleware tower i asynchroniczne mikroserwisy w Rust na hyper, do idiomatycznych, bezpiecznych typowo REST API. - 100axum-code-review
Recenzuje kod frameworka axum pod kątem routingu, użycia extractorów, middleware, zarządzania stanem i obsługi błędów, w tym wzorców axum 0.7+ (State, Path, Query, Json).