Design or review software architecture, API contracts, data models, and module boundaries for the Static Web Server (SWS) project
68
83%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Load this skill when designing new features, refactoring modules, defining configuration interfaces, or reviewing architecture decisions for SWS.
When to load: a new feature spans more than one module, a config option is being added or changed, a new step is needed in the request pipeline, a Cargo feature flag is being introduced, or an architecture decision needs review.
#[cfg(feature = "...")] gate. Users compile only what they needGeneral struct. Precedence (highest→lowest): CLI args → env vars → TOML config → compiled defaultssettings/ → server/opts.rs → handler.rs → static_files.rs
(parse) (init) (pipeline) (serve file)| Module | Responsibility |
|---|---|
settings/ | Parse CLI/env/TOML, merge, validate |
server/ | Bind listener, start HTTP/1 or HTTP/2+TLS, graceful shutdown |
handler.rs | Orchestrate request pre/post processing pipeline |
static_files.rs | Path resolution, index files, directory listing, byte-range, pre-compressed variants |
compression.rs | On-the-fly gzip/deflate/brotli/zstd compression |
compression_static.rs | Serve pre-compressed .br/.gz/.zst files from disk |
security_headers.rs | Append HSTS, CSP, X-Frame-Options, X-Content-Type-Options, Referrer-Policy |
control_headers.rs | Append Cache-Control based on file extension |
cors.rs | CORS pre-flight and header injection |
fs/ | File system utilities: path sanitization (fs/path.rs), metadata (fs/meta.rs), streaming (fs/stream.rs) |
exts/ | HTTP extensions: Accept-Encoding parsing, content-coding negotiation (exts/http.rs, exts/headers/, exts/mime.rs) |
directory_listing/ | HTML/JSON directory index generation |
body.rs | Unified response body type — pub type Body = BoxBody<Bytes, io::Error> (alias, not a struct) |
service.rs | Hyper Service bridge: RouterService → RequestService → RequestHandler |
Every optional feature is both a Cargo feature AND a #[cfg(feature = "...")] gate:
compression → compression.rs + compression_static.rs (meta-feature: compression-brotli/-deflate/-gzip/-zstd)directory-listing → directory_listing/http2 → server/http2.rs (requires tls)tls (base plumbing, no crypto provider) → tls.rs + server/http1_tls.rs. tls-ring (default) or tls-fips selects the providerbasic-auth → basic_auth.rsfallback-page → fallback_page.rsmetrics → metrics.rs. experimental adds tokio-metrics-collector and requires RUSTFLAGS="--cfg tokio_unstable"mem-cache → mem_cache/ (LFU admission + LRU eviction via mini-moka, CompactString keys)The handler's handle() method is the single entry point. The pipeline is linear with three phases:
| # | Step | Phase | Can Short-Circuit? |
|---|---|---|---|
| 1 | Method check | Pre | Yes (405) |
| 2 | Health/metrics | Pre | Yes |
| 3 | CORS validation | Pre | Yes (preflight 204) |
| 4 | Basic auth | Pre | Yes (401) |
| 5 | Maintenance mode | Pre | Yes (503) |
| 6 | Redirects | Pre | Yes (301/302) |
| 7 | Rewrites | Pre | No (modifies URI, continues) |
| 8 | Virtual hosts | Pre | No (selects config, continues) |
| 9 | Markdown negotiation | Pre | No (sets content-type hint, continues) |
| 10 | static_files::handle() | Core | No (always produces a response) |
| 11 | Fallback page | Post | No |
| 12 | CORS headers | Post | No |
| 13 | Markdown content-type | Post | No |
| 14 | Text charset | Post | No |
| 15 | Static compression vary | Post | No |
| 16 | Dynamic compression | Post | No |
| 17 | Cache-Control | Post | No |
| 18 | Security headers | Post | No |
| 19 | Custom headers | Post | No |
When adding a new step, specify its position relative to an existing step by number.
General structCLI arguments, environment variables, and TOML keys all resolve to the same General struct:
--port 8787 ↔ SERVER_PORT=8787 ↔ [general] port = 8787Advanced features (custom headers, rewrites, redirects, virtual hosts) are TOML-only. They live in a separate Advanced struct and require glob/regex patterns.
--no-default-features). Disable them to reduce binary size if not needed/ or /dir/ → directory detected via metadata["index.html", "index.htm"]).html suffix fallbackStatic (on-disk) compression is tried before dynamic (on-the-fly). The client's Accept-Encoding header determines variant selection. SWS honors quality values.
static_files.rs supports Range: bytes= for partial content delivery. Multi-range responses use multipart/byteranges.
4ec71ce
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.