server

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

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 New

func New(opts Options) (*Server, error)

New builds a Server for opts. It does not start listening.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

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).

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully stops all configured listeners.

Jump to

Keyboard shortcuts

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