server

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0 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

Overview

Package server provides the HTTP server of a voter: REST API, health endpoints, runtime frontend configuration and the embedded SPA.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FrontendAuthConfig

type FrontendAuthConfig struct {
	Mode string `json:"mode"`
	// Issuer, ClientID and Scopes are set in oidc mode only (ADR 0027).
	Issuer   string   `json:"issuer,omitempty"`
	ClientID string   `json:"clientId,omitempty"`
	Scopes   []string `json:"scopes,omitempty"`
}

FrontendAuthConfig tells the SPA how to authenticate.

type FrontendConfig

type FrontendConfig struct {
	// Nodes lists API base URLs; empty means "same origin as the page".
	Nodes []string           `json:"nodes"`
	Auth  FrontendAuthConfig `json:"auth"`
}

FrontendConfig is the runtime configuration consumed by the SPA (FA-UI-02).

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the HTTP server of a voter node.

func New

func New(cfg config.Config, log *slog.Logger, ui http.Handler) *Server

New creates a server. ui serves the single-page application for all non-API paths.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the root handler with all routes and middleware.

func (*Server) Run

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

Run serves HTTP on cfg.HTTPAddr until ctx is cancelled, then shuts down gracefully within cfg.ShutdownTimeout.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, ln net.Listener) error

Serve is like Run but uses an existing listener.

func (*Server) WithAPI

func (s *Server) WithAPI(deps api.Deps) *Server

WithAPI provides the services behind the REST API. It must be called before Run. The clock of the API (deps.Now) also drives the rate limits (ADR 0020).

func (*Server) WithReadiness

func (s *Server) WithReadiness(check func() error) *Server

WithReadiness adds a check to /readyz, e.g. the health of the Raft node. It must be called before Run.

Jump to

Keyboard shortcuts

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