Loading
Commits on Source 8
-
Doug Barrett authored
Production-ready HTTP server implementing app.Component with automatic /-/liveness and /-/readiness endpoints. Readiness checks are chainable and run concurrently. Includes request logging and tracing middleware.
-
Doug Barrett authored
Replace gorilla/mux with stdlib net/http as the default router. Expose a Router interface so the underlying implementation can be swapped without breaking consumers. No framework types in the public API. Changes: - Define Router interface with Handle, HandleFunc, Use, ServeHTTP - Default implementation uses Go 1.22+ net/http.ServeMux with method pattern matching (GET /-/liveness, etc.) - Add Config.Router for custom Router injection - Middleware signatures use func(http.Handler) http.Handler (stdlib) - Health check endpoints still registered automatically - Tests exercise the Router interface, not a concrete framework - New tests for Handle, Use middleware, and custom Router injection
-
Doug Barrett authored
Execute readiness checks using goroutines so a slow check does not block others, matching the documented concurrent behavior. Also log JSON encoding failures in writeJSON for debugging.
-
Doug Barrett authored
Use sync.Once for thread-safe lazy initialization of the handler chain in defaultRouter.ServeHTTP, preventing concurrent goroutines from building the chain simultaneously. Also use the server's configured logger in writeJSON instead of slog.Default() for consistency.
-
Doug Barrett authored
Address AGENTS.md review findings: - Add Name field to Config with default "httpserver" for component identification in logs and errors - Use net.ListenConfig.Listen(ctx) in Start to honour context cancellation during bind - Wrap Shutdown errors with the component name - Fix doc.go claim about logging middleware recording duration (it only logs method, path, and status)
-
Doug Barrett authored
Replace the stdlib net/http.ServeMux default with go-chi/chi, exposing Chi's key features through the Router interface while keeping Chi types out of the public API (design requirement from team-tasks#4283). Router interface changes: - Add method-specific registration: Get, Post, Put, Delete, Patch - Add route grouping: Group (scoped middleware), Route (path prefix) - Add sub-router mounting: Mount - Add per-route middleware: With - Add error handler customization: NotFound, MethodNotAllowed - Add URLParam helper for path parameter extraction Architecture changes: - Default Router backed by chi.Mux (wrapped in unexported chiRouter) - Built-in middleware (tracing, logging) registered via Use before user routes, running inside chi's routing context for access to route patterns - Health endpoints (/-/liveness, /-/readiness) handled by Server.ServeHTTP directly, outside the user's route tree - Tracing middleware uses chi.RouteContext for low-cardinality span names (e.g. "GET /users/{id}" instead of "GET /users/42") - Compile-time app.Component assertion added Removed: - routerbench standalone benchmark module (Chi/Gorilla/stdlib comparison served its purpose during the investigation phase) -
Doug Barrett authored
-
Elliot Forbes authored
feat(v2/httpserver): Add HTTP server with built-in health probes See merge request !339 Merged-by:
Elliot Forbes <eforbes@gitlab.com>
Approved-by:
Elliot Forbes <eforbes@gitlab.com>
Reviewed-by: GitLab Duo <gitlab-duo@gitlab.com> Co-authored-by:
dbarrett <dbarrett@gitlab.com>