mirror of
https://github.com/hanzoai/o11y.git
synced 2026-10-30 14:56:15 +00:00
gorilla/mux, otelmux, gorilla/handlers and rs/cors leave go.mod. Every route the runtime serves is a zip route on a zip group: 233 from the apiserver tree, 134 from query-service, 367 total — the same 367 the mount publishes. pkg/http/routing is the one registration surface. It exists because a registration carries three facts zip has no slot for, and the tree this replaces recovered all three PER REQUEST by asking the router what it had just matched: the bound segments, the path template, and the route's declared resources. mux.CurrentRoute(req).GetHandler() was type-asserted back to handler.Handler in two separate packages to re-derive at request time what was already known once at boot. Stating them at registration deletes both lookups. The middleware chain is composed at the LEAF rather than registered ambient, because Audit keys on the route template and Resource resolves the route's declared resources — ambient middleware runs before the router has matched, so both would read an empty route. Per-leaf composition reproduces the order the old tree ran in exactly: match, then middleware, then handler. Duplicate registration now panics at boot; gorilla let the first one win. The Sentry ingest constraint becomes fiber's own guid — a UUID parse instead of a hand-written character class. Paths keep their public brace spelling in the source and in the table; the respelling happens in one function. The standalone server hands its listener to the app, so streams and the websocket upgrade run native fasthttp. Counted, not asserted: routes_test.go in the apiserver pins 233 against the real AddToRouter, routing_test.go pins the table against the router itself. This repo has already shipped 83 typed ops that reached no router while the suite stayed green — an uncalled func is legal Go, so arithmetic is the test. Co-authored-by: Hanzo Dev <[email protected]>
43 lines
2.0 KiB
Go
43 lines
2.0 KiB
Go
package app
|
|
|
|
import (
|
|
"github.com/hanzoai/o11y/pkg/http/middleware"
|
|
"github.com/hanzoai/o11y/pkg/http/routing"
|
|
)
|
|
|
|
// mountLogs registers the logs surface: reads, the field catalog, and log
|
|
// pipelines. 7 routes on its own /v1/o11y/logs subrouter.
|
|
//
|
|
// TWO DISPATCHES, ONE IMPLEMENTATION. These registrations stay: the standalone
|
|
// server has no native router to register an op on. The composed binary
|
|
// reaches the SAME handlers through the typed ops in the repo root's logs.go,
|
|
// which relay here — deleting either half drops one of the two deployments.
|
|
//
|
|
// ORDER IS LOAD-BEARING inside the pipelines block: /pipelines/preview is
|
|
// registered before /pipelines/{version}, so POST .../pipelines/preview reaches
|
|
// the preview handler rather than binding version="preview". Preserved verbatim.
|
|
func (aH *APIHandler) mountLogs(router routing.Router, am *middleware.AuthZ) {
|
|
subRouter := router.Group("/v1/o11y/logs")
|
|
subRouter.Get("", am.ViewAccess(aH.getLogs))
|
|
subRouter.Get("/fields", am.ViewAccess(aH.logFields))
|
|
subRouter.Post("/fields", am.EditAccess(aH.logFieldUpdate))
|
|
subRouter.Get("/aggregate", am.ViewAccess(aH.logAggregate))
|
|
|
|
// log pipelines
|
|
subRouter.Post("/pipelines/preview", am.ViewAccess(aH.PreviewLogsPipelinesHandler))
|
|
subRouter.Get("/pipelines/{version}", am.ViewAccess(aH.ListLogsPipelinesHandler))
|
|
subRouter.Post("/pipelines", am.EditAccess(aH.CreateLogsPipeline))
|
|
}
|
|
|
|
// mountLogsLivetail registers live logs on the shared /v1/o11y subrouter owned
|
|
// by RegisterQueryRangeV3Routes. 1 route.
|
|
//
|
|
// It is NOT on the /v1/o11y/logs subrouter above: that subrouter is registered
|
|
// first and has no /livetail child, so gorilla/mux falls through to the
|
|
// /v1/o11y prefix route and this registration wins. Moving it under mountLogs
|
|
// would change nothing for callers but would change which prefix route matches
|
|
// — left exactly where it was.
|
|
func (aH *APIHandler) mountLogsLivetail(subRouter routing.Router, am *middleware.AuthZ) {
|
|
subRouter.Get("/logs/livetail", am.ViewAccess(aH.O11y.Handlers.QuerierHandler.QueryRawStream))
|
|
}
|