Documentation
¶
Overview ¶
Package serve implements the `apic serve` subcommand: the long-running API server. It is also published as the standalone apic-server binary via the thin cmd/api shim, which forwards its ldflags build stamps through SetBuildInfo.
Index ¶
Constants ¶
const ( // MaxFileSize is the default lumberjack rotation threshold, in // megabytes, for the "max-size" logger arg: once the active log file // reaches this size it is rotated. MaxFileSize = 100 // MB // MaxBackups is the default value for the "max-backups" logger arg: the // maximum number of rotated log files lumberjack retains before the // oldest is deleted. MaxBackups = 11 )
Variables ¶
This section is empty.
Functions ¶
func Args ¶
Args returns the lazily-initialized, process-wide set of logger CLI/config args (filename, level, format, source, max-age, max-size, max-backups, local-time, compress, app-name, app-version) used to configure the lumberjack-backed slog logger for the named application. The defaults are populated on first call via sync.Once — including a filename of /var/log/<app>/<app>.log and error-level, JSON-formatted logging — and the same shared map is returned on every subsequent call regardless of the app argument passed in.
func New ¶
New returns the `apic serve` command, with the fips-version subcommand attached. Flag and config wiring happens in this package's init(); this constructor only re-labels the command for its place in the root apic CLI.
func Serve ¶
Serve builds and runs the API server, blocking until ctx is canceled or a fatal setup/serve error occurs. It reads host/port/TLS/OIDC/rate-limit settings from the api.Args config (host, port, cert, key, oidc, aud, rate-limit, rate-duration), resolves the embedded OpenAPI spec via api.GetSwagger, and constructs the server with CORS, request validation against that spec, the OIDC authenticator, rate limiting, and a trusted proxy of 127.0.0.1/32. server supplies the business-logic handlers (api.ServerInterface) that back the generated routes. Serve returns a non-nil error if the spec cannot be resolved, the server cannot be constructed, or the underlying listener fails; a clean shutdown via ctx cancellation returns nil from the underlying Server.Serve call.
func SetBuildInfo ¶
func SetBuildInfo(buildVersion, buildCommit, buildDate, appName string)
SetBuildInfo forwards the ldflags-stamped build variables from a standalone binary's package main (the linker sets them by fully-qualified symbol name, so they cannot live here). Calling it is optional; the defaults are used when a caller does not.
Types ¶
This section is empty.