Documentation
¶
Index ¶
- func RegisterHealthz(srv *HTTPServer, checks ...HealthChecker)
- func RegisterPprof(srv *HTTPServer, middleware ...gin.HandlerFunc)
- type HTTPServer
- func (s *HTTPServer) DELETE(path string, handler ...gin.HandlerFunc)
- func (s *HTTPServer) Engine() *gin.Engine
- func (s *HTTPServer) GET(path string, handler ...gin.HandlerFunc)
- func (s *HTTPServer) Group(path string, middleware ...gin.HandlerFunc) *gin.RouterGroup
- func (s *HTTPServer) PATCH(path string, handler ...gin.HandlerFunc)
- func (s *HTTPServer) POST(path string, handler ...gin.HandlerFunc)
- func (s *HTTPServer) PUT(path string, handler ...gin.HandlerFunc)
- func (s *HTTPServer) Start(ctx context.Context, ready func()) error
- func (s *HTTPServer) Stop(ctx context.Context) error
- func (s *HTTPServer) Use(middleware ...gin.HandlerFunc)
- type HealthChecker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHealthz ¶
func RegisterHealthz(srv *HTTPServer, checks ...HealthChecker)
RegisterHealthz registers GET /healthz. Should be called before authentication middleware is applied so that K8s probes do not receive 401.
func RegisterPprof ¶
func RegisterPprof(srv *HTTPServer, middleware ...gin.HandlerFunc)
RegisterPprof registers /debug/pprof/* routes. Not enabled by default — call explicitly in Setup when needed.
WARNING: pprof endpoints expose sensitive runtime data (heap contents, goroutine stacks). Pass authentication middleware to restrict access:
server.RegisterPprof(srv, authMiddleware)
Types ¶
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer implements the chok.Server interface using Gin.
func NewHTTPServer ¶
func NewHTTPServer(opts *config.HTTPOptions) *HTTPServer
func (*HTTPServer) DELETE ¶
func (s *HTTPServer) DELETE(path string, handler ...gin.HandlerFunc)
func (*HTTPServer) Engine ¶
func (s *HTTPServer) Engine() *gin.Engine
func (*HTTPServer) GET ¶
func (s *HTTPServer) GET(path string, handler ...gin.HandlerFunc)
func (*HTTPServer) Group ¶
func (s *HTTPServer) Group(path string, middleware ...gin.HandlerFunc) *gin.RouterGroup
func (*HTTPServer) PATCH ¶
func (s *HTTPServer) PATCH(path string, handler ...gin.HandlerFunc)
func (*HTTPServer) POST ¶
func (s *HTTPServer) POST(path string, handler ...gin.HandlerFunc)
func (*HTTPServer) PUT ¶
func (s *HTTPServer) PUT(path string, handler ...gin.HandlerFunc)
func (*HTTPServer) Start ¶
func (s *HTTPServer) Start(ctx context.Context, ready func()) error
Start binds the port, calls ready(), then blocks serving until Stop is called.
Stop can be called at any point during Start (including before ready). Start uses stopCh to detect Stop between listen and Serve, closing the race window.
func (*HTTPServer) Stop ¶
func (s *HTTPServer) Stop(ctx context.Context) error
Stop gracefully shuts down the server. It is idempotent and safe to call at any stage.
Closing stopCh ensures Start detects Stop even if called between listen and Serve.
func (*HTTPServer) Use ¶
func (s *HTTPServer) Use(middleware ...gin.HandlerFunc)
type HealthChecker ¶
HealthChecker is a function that returns nil if healthy, error if not.