feat: enhance /api/v1/status endpoint with full monitoring data #86
Reference in New Issue
Block a user
Delete Branch "feature/enhance-status-endpoint"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Enhances the
/api/v1/statusendpoint to return comprehensive monitoring state instead of just{"status": "ok"}.Changes
The endpoint now returns:
All data is derived from the existing
state.GetSnapshot(), consistent with how the dashboard works. No configuration details (webhook URLs, API tokens) are exposed.Example response structure
closes #73
The /api/v1/status endpoint previously returned only {"status": "ok"}. It now returns comprehensive monitoring state including: - Summary counts (domains, hostnames, ports, certificates with breakdown) - Full domain state with nameservers and last check timestamps - Hostname state with per-nameserver DNS records and status - Port state with open/closed status and associated hostnames - TLS certificate state with CN, issuer, expiry, SANs, and status - Last updated timestamp for the overall monitoring state All data is derived from the existing state snapshot, providing operational visibility without exposing configuration details like webhook URLs or API tokens.✅ Review: PASS
Summary
Clean, well-implemented enhancement that transforms the
/api/v1/statusendpoint from a trivial{"status":"ok"}into a comprehensive monitoring state API. Directly addresses issue #73.What was reviewed
internal/handlers/status.go(+200 / -5 lines)docker build .passes (includesmake check: fmt, lint, tests)Correctness
h.state.GetSnapshot()— the same snapshot mechanism the dashboard uses. Consistent and correct.GetSnapshot()returns a shallow copy.sort.Strings()applied to nameserver and hostname lists for stable JSON responses.statusResponsestruct cleanly separates concerns (counts, domains, hostnames, ports, certificates).Security
Errorfield fromNameserverRecordStateandCertificateStateis intentionally excluded — only thestatusfield ("ok"/"error") is surfaced, which avoids leaking internal network diagnostics through this unauthenticated endpointResponse structure
Well-designed:
countssummary for quick programmatic checkslastCheckedtimestamps on every entitylastUpdatedat the response level for overall state freshnessstatus: "ok"field preservedREADME
The HTTP API table already describes this endpoint as "Current monitoring state" — that description is now accurate. No specific response format is documented for any endpoint in the README, so this is consistent.
Scope
No scope creep. Single file, single purpose, directly addressing the issue requirements.