First migrated endpoint onto the SX host. lib/host is a thin wiring layer: a host handler is a Dream handler (request->response) that calls a subsystem public API and serialises via a shared JSON envelope. - handler.sx: host/ok, host/ok-status, host/error, host/json-status (Dream's dream-json is 200-only), host/query-int - router.sx: host/make-app assembles per-domain route groups + /health probe into one dream-router (reuses dr/flatten-routes) - feed.sx: GET /feed reads feed/all + stream combinators, recent-first, with ?actor= filter and ?limit= cap - 3 test suites incl. a golden test (body == subsystem recent stream + envelope) - conformance.sh mirrors lib/dream's runner Builds on dream-on-sx (merged, gate green 480/480) rather than a throwaway native request model; collapses most of plan Phase 4 into Phase 1. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
20 lines
1.0 KiB
Plaintext
20 lines
1.0 KiB
Plaintext
;; lib/host/router.sx — Host application assembly. A host app is a single Dream
|
|
;; router built from per-domain route groups, with a built-in health endpoint and
|
|
;; a JSON 404 fallback so the native OCaml HTTP server has one entry point:
|
|
;; request -> response. Each subsystem contributes a list of Dream routes (see
|
|
;; lib/host/feed.sx); host/make-app concatenates them under one router.
|
|
;; dr/flatten-routes (Dream) flattens the nested groups, so a group is just a list
|
|
;; of routes. Depends on lib/dream/router.sx + lib/host/handler.sx.
|
|
|
|
;; Liveness probe — GET /health -> 200 {"ok":true,"data":"healthy"}.
|
|
(define host/health-route
|
|
(dream-get "/health" (fn (req) (host/ok "healthy"))))
|
|
|
|
;; Build the host app from a list of route groups (each a list of Dream routes).
|
|
;; The health route is always mounted first; Dream's router returns a JSON-free
|
|
;; 404 for unmatched paths, which host endpoints override per-domain as needed.
|
|
(define host/make-app
|
|
(fn (groups)
|
|
(dream-router
|
|
(cons host/health-route groups))))
|