feat(v2/httpserver): Add HTTP server with built-in health probes

Context

Part of the LabKit v2 package decomposition from the UAM PoC (!314).

Tracking issue: gitlab-org/quality/quality-engineering/team-tasks#4283 (closed) Parent epic: gitlab-org/quality#360

What's in this MR?

  • v2/httpserver package: production-ready HTTP server implementing app.Component
    • Abstract Router interface backed by chi internally, with no framework types in the public API
    • Method-specific route registration: Get, Post, Put, Delete, Patch
    • Route grouping with scoped middleware via Group and Route
    • Per-route middleware via With
    • Sub-router mounting via Mount
    • Path parameter extraction via URLParam
    • Custom NotFound and MethodNotAllowed handlers
    • Custom Router injection via httpserver.Config for alternative implementations
    • All middleware uses the standard func(http.Handler) http.Handler signature
    • Automatic /-/liveness and /-/readiness endpoints (handled by Server directly)
    • Chainable readiness checks that run concurrently
    • Built-in request tracing (with low-cardinality span names from route patterns) and logging middleware
    • Configurable graceful shutdown with timeout
    • Compile-time app.Component assertion

Dependencies

Depends on !337 (merged) (v2/app package).

Proof of Work

ok  	gitlab.com/gitlab-org/labkit/v2/httpserver	0.503s

30 tests covering: route registration (Handle, HandleFunc, method-specific), middleware (Use, With, Group), route grouping (Group, Route), mounting, URL parameters, custom error handlers, 404 behavior, custom router injection, lifecycle (Start/Shutdown, port binding, bad address), tracing (span creation, route pattern names, 5xx errors, W3C context propagation), logging, and health checks (liveness, readiness with passing/failing checks, content type, chaining).

Edited by Doug Barrett

Merge request reports

Loading