feat(server): serve an endpoint index at the root path #51

Merged
rcsheets merged 1 commit from feat/root-index into main 2026-07-23 02:18:19 +00:00
Owner

GET / previously answered 404. This registers the root (as "GET /{$}", so unknown paths keep their 404 and non-GET on / gets 405) with an orientation page: the endpoint list plus the server name, build version, and served model.

  • JSON by default (curl, scripts); a small HTML table with clickable GET links when the Accept header names text/html (browsers).
  • Routes now register through a handle helper that records each route in the index as it registers it, so the index cannot drift from the route table.
  • The deprecated /healthz alias bypasses the helper deliberately, so the index does not advertise an endpoint new probes should not adopt.
  • During a model load, / keeps the Loading handler's existing 503 + Retry-After.

TestIndex covers the JSON shape, endpoint completeness (including /healthz's exclusion), the HTML negotiation, and that unknown paths still 404.

🤖 Generated with Claude Code

GET / previously answered 404. This registers the root (as "GET /{$}", so unknown paths keep their 404 and non-GET on / gets 405) with an orientation page: the endpoint list plus the server name, build version, and served model. - JSON by default (curl, scripts); a small HTML table with clickable GET links when the Accept header names text/html (browsers). - Routes now register through a `handle` helper that records each route in the index as it registers it, so the index cannot drift from the route table. - The deprecated /healthz alias bypasses the helper deliberately, so the index does not advertise an endpoint new probes should not adopt. - During a model load, / keeps the Loading handler's existing 503 + Retry-After. TestIndex covers the JSON shape, endpoint completeness (including /healthz's exclusion), the HTML negotiation, and that unknown paths still 404. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(server): serve an endpoint index at the root path
All checks were successful
ci / test_and_build (pull_request) Successful in 21s
220826382e
GET / previously answered 404. Register the root (as "GET /{$}", so
unknown paths keep their 404) with an orientation page: the endpoint
list plus the server name, build version, and served model. JSON by
default; a small HTML table when the Accept header asks for text/html.

Routes now register through a helper that records each one in the index
as it registers it, so the index cannot drift from the route table. The
deprecated /healthz alias bypasses the helper deliberately, keeping it
out of the index.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator

Automated review by pr-reviewer v0.37.0 | Safety Check | Claude Sonnet 5 | tracking id r-61797d-5806dc
This is an AI-generated review and may contain mistakes.

Status: Completed


⚠️ The primary review (Mistral Small) failed. The review below is from Claude Sonnet 5, which reviewed the same diff.

Verdict: LGTM — The PR is a contained, additive feature (root index endpoint) with proper escaping, correct route-matching semantics, and test coverage; nothing alarming found.

Reviewed the diff: adds a root "GET /{$}" index route that lists registered endpoints, plus a handle helper that records routes as they register. Checked for common issues:

  • Route registration change: uses GET /{$} (exact match pattern in Go 1.22+ ServeMux), so it won't shadow other paths or the catch-all 404 — confirmed by the included test for /nope still 404.
  • HTML output escapes path/description/version/model with html.EscapeString, so no obvious XSS vector even though model ID could theoretically be attacker-influenced.
  • /healthz intentionally bypasses the handle helper so it isn't advertised — deliberate and documented, not an oversight.
  • No secrets, credentials, or unrelated files included.
  • Test coverage included for JSON shape, HTML negotiation, endpoint completeness, and 404 behavior.
  • Behavior change (previously 404 on /, now 200) is the intended purpose of the PR, not accidental.

Nothing alarming stands out — this is a contained, additive feature with reasonable test coverage.

*Automated review by [pr-reviewer](https://git.brooktrails.org/brooktrails/pr-reviewer) v0.37.0 | Safety Check | Claude Sonnet 5 | tracking id `r-61797d-5806dc`* *This is an AI-generated review and may contain mistakes.* **Status:** ✅ Completed --- > ⚠️ The primary review (**Mistral Small**) failed. The review below is from **Claude Sonnet 5**, which reviewed the same diff. **✅ Verdict: LGTM** — The PR is a contained, additive feature (root index endpoint) with proper escaping, correct route-matching semantics, and test coverage; nothing alarming found. Reviewed the diff: adds a root "GET /{$}" index route that lists registered endpoints, plus a `handle` helper that records routes as they register. Checked for common issues: - Route registration change: uses `GET /{$}` (exact match pattern in Go 1.22+ ServeMux), so it won't shadow other paths or the catch-all 404 — confirmed by the included test for `/nope` still 404. - HTML output escapes path/description/version/model with `html.EscapeString`, so no obvious XSS vector even though model ID could theoretically be attacker-influenced. - `/healthz` intentionally bypasses the `handle` helper so it isn't advertised — deliberate and documented, not an oversight. - No secrets, credentials, or unrelated files included. - Test coverage included for JSON shape, HTML negotiation, endpoint completeness, and 404 behavior. - Behavior change (previously 404 on `/`, now 200) is the intended purpose of the PR, not accidental. Nothing alarming stands out — this is a contained, additive feature with reasonable test coverage.
rcsheets deleted branch feat/root-index 2026-07-23 02:18:19 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
brooktrails/gllm!51
No description provided.