Skip to content

HTTP Server & API Layer: async server with Pinchtab-compatible routes #5

@justrach

Description

@justrach

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions