httpserver

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package httpserver assembles the chi router: middleware stack, operational endpoints (/healthz, /readyz, /metrics), the mounted /api/v0 handler, and the embedded SPA fallback. It may import everything below it in the tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(d Deps) http.Handler

New builds the top-level HTTP handler.

Types

type Deps

type Deps struct {
	Log *slog.Logger
	// Handlers implements the generated API surface. Nil mounts a 501 catch-all.
	Handlers *handlers.Server
	Ready    ReadyFunc
	// Sessions resolves cookies to identities; nil skips session handling.
	Sessions *auth.SessionStore
	// BaseOrigin is the deployment origin for the CSRF check (required when
	// Sessions is set). CORSDevOrigin optionally allows the Vite dev server.
	BaseOrigin    string
	CORSDevOrigin string
	// WSHandler serves GET /api/{v0,v1}/ws (the live scoreboard socket). Nil disables it.
	WSHandler http.Handler
	// V0Sunset is the date advertised in the /api/v0 Sunset header (RFC 8594). The zero
	// value still emits a header (an ancient date); production passes cfg.APIV0Sunset.
	V0Sunset time.Time
	// Tokens resolves `Authorization: Bearer` API tokens; nil disables token auth.
	Tokens *auth.TokenService
	// Limiter rate-limits token requests by token identity; nil disables that limit.
	Limiter         *redisx.Limiter
	TokenRateBurst  int
	TokenRateWindow time.Duration
	// TrustProxy mirrors OSCTF_TRUST_PROXY. When false the server warns once if it
	// receives a forwarded header, since a proxy is likely in front but its client IPs
	// are being ignored (every request would then key to the proxy IP).
	TrustProxy bool
}

Deps are the inputs to New.

type ReadyFunc

type ReadyFunc func(ctx context.Context) map[string]string

ReadyFunc reports readiness: it returns a map of component name -> failure reason. An empty map means everything is reachable.

Jump to

Keyboard shortcuts

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