Documentation
¶
Overview ¶
Package httpserver runs an HTTP server with graceful shutdown.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run starts the HTTP server and blocks until ctx is cancelled, then shuts down gracefully within a 10s timeout.
func RunListeners ¶ added in v0.2.0
RunListeners serves all configured listeners under one coordinated lifecycle.
func RunPair ¶ added in v0.2.0
func RunPair(ctx context.Context, apiAddr string, apiHandler http.Handler, metricsAddr string, metricsHandler http.Handler, log *slog.Logger) error
RunPair serves the API and an optional metrics listener under one coordinated lifecycle: either listener's failure cancels the shared context so the other listener is joined via the same graceful shutdown, instead of leaking a goroutine. metricsHandler nil means no metrics listener is started at all.
Types ¶
type Timeouts ¶ added in v0.2.0
Timeouts bound a connection's lifetime. Zero fields take the package defaults.
ReadHeaderTimeout is the slowloris guard and is always applied. WriteTimeout in Go covers the span from the end of the request headers to the end of the response write, so it also bounds reading a large request body: the default is generous enough for a retained source archive on a slow link while still reaping a stuck connection. ReadTimeout is deliberately left unset for that same reason.