Files
zeekay 46c6241c52 Spell every o11y caller /v1/o11y
The server moved off /api/vN; the integration suite, handler tests,
install.sh's health wait and the docs still called the old tree.

Claude-Session: https://claude.ai/code/session_01TUxvfuta1Z44KVNYuAz71F
2026-09-24 15:05:09 -07:00

29 lines
1.6 KiB
Go

package app
import (
"github.com/hanzoai/o11y/pkg/http/middleware"
"github.com/hanzoai/o11y/pkg/http/routing"
)
// mountRules registers alert-rule evaluation and rule state history. 5 routes.
//
// rules + rules/{id} (GET/POST/PUT/DELETE/PATCH) are NOT here: they are served
// by o11yapiserver/ruler.go, the one handler /v1/o11y/rules resolves to.
// ALL of these routes are ALSO declared as typed ops at the module's mount seam
// (rulesalerts.go in the repo root) — the v1 history reads and the legacy
// /testRule — which is what carries them into the composed document, the SDK,
// the CLI and the agent surface. That is a second DISPATCH, never a second
// implementation: the ops answer by handing the call back to this router, so
// the handlers below stay the one place the work is performed — and the gates
// declared here (ViewAccess, EditAccess) stay the one place access is decided.
// Both halves are needed — the ops serve the composed binary, this router
// serves the standalone process, which has no native router to register an op
// on — so deleting either drops one of the two deployments.
func (aH *APIHandler) mountRules(router routing.Router, am *middleware.AuthZ) {
router.Post("/v1/o11y/testRule", am.EditAccess(aH.testRule))
router.Post("/v1/o11y/rules/{id}/history/stats", am.ViewAccess(aH.getRuleStats))
router.Post("/v1/o11y/rules/{id}/history/timeline", am.ViewAccess(aH.getRuleStateHistory))
router.Post("/v1/o11y/rules/{id}/history/top_contributors", am.ViewAccess(aH.getRuleStateHistoryTopContributors))
router.Post("/v1/o11y/rules/{id}/history/overall_status", am.ViewAccess(aH.getOverallStateTransitions))
}