server

package
v0.0.0-...-5e5371a Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: AGPL-3.0 Imports: 45 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIV2Option

type APIV2Option func(*apiV2Config)

APIV2Option configures the API-v2 GraphQL handler.

func WithGraphQLIntrospection

func WithGraphQLIntrospection() APIV2Option

type Option

type Option func(*Server) error

Option defines a functional option for Server.

func WithAddress

func WithAddress(addr string) Option

WithAddress sets the server address.

func WithAllowedOrigins

func WithAllowedOrigins(origins []string) Option

WithAllowedOrigins restricts the CORS allowed origins. Defaults to same-origin only (empty slice) when not set. Pass explicit origins for deployments that serve the UI from a different host than the API.

func WithApiV2

func WithApiV2(stack Stack, opts ...APIV2Option) Option

func WithEnforcer

func WithEnforcer(enforcer auth.Enforcer) Option

func WithOidc

func WithOidc(oidcClient *auth.OIDCClient) Option

func WithPort

func WithPort(port uint) Option

func WithReadinessCheck

func WithReadinessCheck(check func(context.Context) error) Option

WithPort sets the server port. WithReadinessCheck makes /ready also depend on a dependency probe (typically the database), so a pod that cannot reach it is taken out of the Service instead of failing requests. /health stays dependency-free on purpose: restarting pods does not fix a database outage.

func WithTLS

func WithTLS(cfg TLSConfig) Option

WithTLS serves HTTPS instead of HTTP.

func WithVersion

func WithVersion(version, sha string) Option

WithVersion records the build identity so it can be served to clients.

The UI is embedded in this binary (see ui.Assets), so these values describe the frontend being served as much as the backend, which is what lets the update prompt name the version it is offering.

type Server

type Server struct {
	auth.Enforcer

	*http.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(opts ...Option) (*Server, error)

func (*Server) ListenAndServe

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

func (*Server) RegisterMiddlewares

func (s *Server) RegisterMiddlewares()

func (*Server) RegisterRoutes

func (s *Server) RegisterRoutes()

Routes registers all HTTP routes and handlers on the server's router.

type Stack

type Stack struct {
	Incidents             inbound.IncidentService
	Messages              inbound.MessageService
	Layers                inbound.LayerService
	Features              inbound.FeatureService
	Access                inbound.AccessService
	Schadenplaetze        inbound.SchadenplatzService
	Resources             inbound.ResourceService
	Timeline              inbound.TimelineService
	Tiles                 inbound.TileService
	IncidentAccessChecker outbound.IncidentAccessChecker
	GlobalAccessChecker   outbound.GlobalAccessChecker
	AccessQueries         outbound.AccessQueries
	Queries               outbound.Queries
	// MaxAttachmentSize is the maximum allowed size in bytes for file attachments.
	// Zero means no server-side limit (domain validation still applies).
	MaxAttachmentSize int64
}

Stack contains the application dependencies exposed by the server.

type TLSConfig

type TLSConfig struct {
	// CertFile and KeyFile point at a PEM key pair managed outside the server.
	CertFile string
	KeyFile  string

	// ACMEDomains enables ACME when non-empty. Certificates are issued for
	// these hostnames only.
	ACMEDomains []string
	// ACMEEmail is registered with the CA for expiry notices. Optional.
	ACMEEmail string
	// ACMECacheDir persists account keys and certificates across restarts.
	// Without it every restart requests a new certificate and will hit the
	// CA's rate limits.
	ACMECacheDir string
	// ACMEDirectoryURL overrides the CA. Empty means Let's Encrypt production;
	// point it at the staging directory while testing.
	ACMEDirectoryURL string
}

TLSConfig selects how the server obtains its certificate. Exactly one of the two modes must be configured: a static key pair, or ACME.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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