- App.get/post/put/delete_(pattern, take h: Handler) — the take-interface shape probe-proven release + ASan before landing; retires plan-16 deviation 1; delete_ because delete is the query keyword - dispatch matches path-first: wrong method on a known path answers 405 with Allow in registration order; unknown path stays 404 - HEAD routed as GET, body suppressed, Content-Length names the body a GET would carry (serialize gains head_only) - Logging middleware (request line to stderr) ships in router/ - set_header(mut r, name, value) — the builder escape hatch - web-app registers through the helpers (dogfood); README documents all - gate grows 14 -> 16: 405+Allow, HEAD-vs-GET content-length equality - all gates green: web-app 16/0, woc-test 540/0, oop-e2e 89/0, deps-accept 8/0, log-watcher 7/0, employee 8/0 - board/story: iteration 17 parked (spec+plan ready on library-internal), 16 carries the v1-polish landing, order list updated Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| http | ||
| router | ||
| app.wo | ||
| README.md | ||
| wo.toml | ||
writeonce-framework
A web framework written in writeonce, consumed as a [deps] dependency
(iteration 15). Spec: docs/superpowers/specs/2026-08-18-web-framework-design.md §B.
[deps]
writeonce-framework = { git = "https://github.com/shoneyj/writeonce-framework", rev = "v0.1.0" }
What it is
- HTTP/1.1 server core (
http/): request parsing (Content-Lengthbodies, %-decoded paths and query strings), response serialization, a blocking serve loop that answers 400 to malformed requests, 500 to trapping handlers (and survives), closes every fd, and honors SIGTERM. Connection policy: pipelined requests are served on one connection; idle connections close after the response — on a single-threaded server a parked keep-alive connection would blockacceptand starve every other client, so closing is the correct shape until shards/fibers (8/11). A proxy in front simply reconnects. - Router (
router/): method + path table with:paramcaptures intoreq.params; first match wins; a known path with the wrong method is 405 with theAllowheader (registration order); no matching path is the framework's 404. HEAD is served free: routed as GET, body suppressed,Content-Lengthstill names the body a GET would carry. - Registration helpers:
app.get/post/put/delete_(pattern, handler)push the route for you (delete_becausedeleteis the query keyword);app.add(Route { ... })stays for anything else. A request-lineLoggingmiddleware ships inrouter/, andset_header(resp, name, value)is the escape hatch for headers the builders don't set. - Handlers without closures: the language has no function values by
doctrine, so a route handler is a class satisfying the
Handlerinterface (fn handle(req: Req) -> Resp), dispatched structurally — a non-conforming handler is a compile error (WO-E205). Middleware is its own interface (fn before(req: Req) -> ?Resp; nil = continue, aRespshort-circuits). - Data layer for free: handlers use
@table+ the query surface directly — durable, compiler-checked persistence in the same binary. No ORM, no database server.
Honest limits (v1, all deliberate)
- Single-threaded, blocking — one request at a time. Concurrency arrives underneath this same surface with the shard/fiber iterations (8/11).
- TLS: none, anywhere. Deploy behind nginx/caddy; the proxy terminates TLS+ALPN and gives browsers HTTP/2 while this backend speaks HTTP/1.1 keep-alive. See the web-app sample's README for the nginx sketch.
Content-Lengthbodies only (no chunked encoding), no WebSockets/SSE, JSON-first (no templates).
The consuming sample
docs/examples/web-app — a small storefront importing this framework
through [deps]. Its acceptance (just web-app) exercises the whole chain:
fetch → lock → build → serve → durable restart.