refactor(v2/httpserver): remove Router interface, accept http.Handler

Context

The chi router discussion reached consensus:

  1. Don't abstract the router. Hyrum's Law makes swappability moot in practice.
  2. Modern stdlib is sufficient for most services. Chi is fine when needed.
  3. LabKit's value is middleware (tracing, access logging, correlation IDs), not routing.
  4. Define the minimum, not the implementation.

The decision is formalized in ADR 001 (handbook !18825).

What's in this MR?

Remove the Router interface from v2/httpserver. Consumers bring their own router (stdlib http.ServeMux, chi, or any http.Handler) and pass it via Config.Handler.

  • Remove Router interface (17 methods), chiRouter adapter, newDefaultRouter(), Server.Router() accessor
  • Replace Config.Router Router with Config.Handler http.Handler
  • Simplify URLParam to delegate to r.PathValue() (Go 1.22+, works with both stdlib and chi v5.1+)
  • Add SetRoutePattern/RoutePattern context helpers for low-cardinality tracing span names. Uses a mutable holder pattern so inner middleware can communicate the route pattern back to the outer tracing middleware.
  • Remove github.com/go-chi/chi/v5 dependency from v2/go.mod
  • Rewrite tests, docs, examples for the new handler-based API

Proof of work

$ cd v2 && go test ./httpserver/ -count=1
ok  	gitlab.com/gitlab-org/labkit/v2/httpserver	0.534s

$ cd v2 && go test ./... -count=1
ok  	gitlab.com/gitlab-org/labkit/v2/app           0.501s
ok  	gitlab.com/gitlab-org/labkit/v2/httpserver     2.096s
# ... all packages pass

$ ./scripts/golangci-lint.sh
# clean
Edited by Doug Barrett

Merge request reports

Loading