Web & API FrameworkM5
llhttp v9.4.4, Router, Params & Protocol Limits
20 bilingual Web/API builtins, chunked parsing, deterministic 400–431 enforcement, and CORS.
6 min readUpdated: v0.8.0-rc Reference
Pinned llhttp v9.4.4 Adapter
runtime/hadid_web.c wraps verbatim `nodejs/llhttp` v9.4.4 (MIT, SHA-256 pinned) behind 20 TR/EN builtins without leaking external C types.
- Deterministic protocol errors:
400,404,405(withAllow:),408,413,431. web_cors(origin)handlesOPTIONSpreflight (204) and setsAccess-Control-Allow-Credentials: true+Vary: Originfor explicit origins.- Per-request arenas reset cleanly on every
web_acceptturn; sockets close automatically on abort.
hadidLocal CLI: hadid run
import "web.had";web_limits(262144, 5000);web_cors("https://tasks.example.com");web_route("GET", "/healthz", "Liveness probe");web_route("GET", "/api/items/:id", "Get item by ID");match (web_listen(8080)) { Err(e) => { assert(false, "listen failed: " + e); } Ok(port) => { while (web_accept(0)) { if (web_match("GET", "/healthz")) { res_json(200, "{\"status\":\"ok\"}"); } else if (web_match("GET", "/api/items/:id")) { match (req_param("id")) { Some(id) => { res_json(200, "{\"id\":" + json_str(id) + "}"); } None => { respond_error(400, "missing_id", "ID required"); } } } } web_close(); }}