Documentation
¶
Overview ¶
Package server assembles the HTTP/HTTPS listeners for the Freizone API, handling the three supported TLS modes (off, manual, autocert) and graceful shutdown.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BodyLimitOverride ¶ added in v0.10.0
type BodyLimitOverride struct {
// PathPrefix is matched against the request path with strings.HasPrefix,
// so "/v1/blobs" also covers "/v1/blobs/{id}".
PathPrefix string
MaxBytes int64
}
BodyLimitOverride raises (or lowers) the request-body cap for one route prefix. Needed because the cap is applied here, as the outermost body wrapper -- a handler can only ever tighten what it receives, never widen it, so a route that legitimately carries more than a chat message (the blob transport, see internal/api/blobs.go) has to be declared up front.
type Options ¶
type Options struct {
Domain string
HTTPAddr string
HTTPSAddr string
TLSMode config.TLSMode
TLSCertFile string
TLSKeyFile string
AutocertCacheDir string
Handler http.Handler
Logger *slog.Logger
// MaxRequestBodyBytes caps every request body -- see withMaxBody.
MaxRequestBodyBytes int64
// BodyLimitOverrides raises that cap for specific route prefixes (the
// blob transport), since the cap is applied outside the handler and so
// cannot be widened from within one.
BodyLimitOverrides []BodyLimitOverride
}
Options configures how the server terminates connections and serves Handler.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps one or two http.Server instances, depending on TLS mode.
func (*Server) ListenAndServe ¶
ListenAndServe starts all configured listeners and blocks until they have all stopped -- either because Shutdown was called (returns nil) or because one of them failed to start/run (returns that error, after best- effort shutting down the others).