server

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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

type HealthChecker func(ctx context.Context) error

HealthChecker is a function that returns nil if healthy, error if not.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL