server

package
v0.0.0-...-f1e0a5e Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HealthCheck

type HealthCheck func(ctx context.Context) error

HealthCheck is a function that returns an error if the check fails.

type Option

type Option func(*Server)

Option configures the server.

func WithAddr

func WithAddr(addr string) Option

WithAddr sets the listen address.

func WithLogger

func WithLogger(l *slog.Logger) Option

WithLogger sets the server logger.

func WithMetrics

func WithMetrics(m *telemetry.Metrics) Option

WithMetrics attaches a metrics collector.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server provides an HTTP server with health, metrics, and admin endpoints.

func New

func New(opts ...Option) *Server

New creates a production server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts the HTTP server with graceful shutdown on SIGINT/SIGTERM.

func (*Server) Mux

func (s *Server) Mux() *http.ServeMux

Mux returns the underlying ServeMux for adding custom routes.

func (*Server) OnShutdown

func (s *Server) OnShutdown(fn func())

OnShutdown registers a function to call during graceful shutdown.

func (*Server) RegisterHealthCheck

func (s *Server) RegisterHealthCheck(name string, check HealthCheck)

RegisterHealthCheck adds a named health check.

func (*Server) SetReady

func (s *Server) SetReady(ready bool)

SetReady marks the server as ready to accept traffic.

Jump to

Keyboard shortcuts

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