Documentation
¶
Overview ¶
Package server wires the HTTP surface: middleware, health probes, metrics, graceful shutdown, and a chi router that other packages mount routes onto.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
Addr string
ShutdownTimeout time.Duration
// APIKey, when non-empty, gates /metrics behind the same bearer token used
// by the /v1 routes.
APIKey string
}
Options configures the server without importing the config package.
type ReadinessFunc ¶
ReadinessFunc reports whether the service is ready to serve traffic. A nil error means ready; a non-nil error is surfaced on /readyz.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server owns the HTTP server and its router.
func New ¶
New builds a Server with base middleware, /healthz, /readyz and /metrics. Additional routes are mounted via Router before calling Run.
func (*Server) Run ¶
Run starts the HTTP server and blocks until ctx is cancelled, then performs a graceful shutdown bounded by the configured timeout.
func (*Server) SetReady ¶
func (s *Server) SetReady(fn ReadinessFunc)
SetReady installs the readiness check used by /readyz.