Overview
Build the HTTP API server using std.http.Server with arena-per-request allocation and full route coverage.
Tasks
- HTTP server setup with configurable port and address
- Arena-per-request allocator pattern (alloc on request start, bulk free on end)
- Router/dispatch: match method + path → handler function
- Routes to implement:
GET /health — Chrome status + tab count
GET /tabs — list open tabs
GET /snapshot — a11y tree (params: tabId, filter, depth, format, diff)
GET /screenshot — JPEG capture (params: tabId, quality, encoding)
GET /text — readable text extraction (params: tabId, readability)
POST /navigate — navigate tab to URL
POST /action — click/type/fill/scroll by ref
POST /evaluate — execute JS
POST /tab — create/close tabs
POST /crawl — batch crawl URLs
POST /crawl/r2 — crawl + upload to R2
POST /crawl/kafka — crawl + stream to Kafka
- JSON response helpers:
jsonResp(), jsonErr()
- Middleware: auth (check PINCHTAB_SECRET header), CORS, request logging
Acceptance Criteria
- Server starts, serves /health
- All routes return proper JSON
- Auth middleware blocks unauthorized requests
- Arena allocator frees all memory per request
Overview
Build the HTTP API server using
std.http.Serverwith arena-per-request allocation and full route coverage.Tasks
GET /health— Chrome status + tab countGET /tabs— list open tabsGET /snapshot— a11y tree (params: tabId, filter, depth, format, diff)GET /screenshot— JPEG capture (params: tabId, quality, encoding)GET /text— readable text extraction (params: tabId, readability)POST /navigate— navigate tab to URLPOST /action— click/type/fill/scroll by refPOST /evaluate— execute JSPOST /tab— create/close tabsPOST /crawl— batch crawl URLsPOST /crawl/r2— crawl + upload to R2POST /crawl/kafka— crawl + stream to KafkajsonResp(),jsonErr()Acceptance Criteria