routes

package
v0.0.57 Latest Latest
Warning

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

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

README

routes

Defines and serves the Gin HTTP router for the API server. Responsible for wiring handler functions to paths and methods, applying middleware, and starting the HTTP listener on the host and port from config. All API endpoints are registered under the /api/v1 prefix. A Swagger UI is served at /swagger/ and is auto-generated from source annotations using swag init. Route handlers are organized into subpackages by domain — agent, scoring, users, graphs, competition control, and miscellaneous — and registered from this package. Route registration is exported separately from listener startup so tests can mount the full production route tree against their own middleware stack.

Whether the PostgreSQL sink is configured determines which routes are active. Routes that require database access are substituted at startup with handlers that return 501 Not Implemented when no sink is configured; the database middleware is similarly replaced with a no-op. Agent-facing routes for fetching checks and submitting scores are always registered, because they are expected to keep working in a database-less deployment — they degrade internally instead, skipping the reads they cannot perform.

The competition control routes are the one group registered as several paths against a single handler. Rather than accepting the desired state in a request body, each pause and unpause path binds its state and pause kind at registration time, so the set of reachable transitions is fixed by the router itself.

Documentation

Overview

Package routes contains all of the Gin HTTP API logic. This is includes which functions are responsible for which paths and methods, user input parsing and validation, as well as request logging and error handling. Most Gin handler functions are located in subpackages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRoutes

func RegisterRoutes(router *gin.Engine, s config.Sinks)

RegisterRoutes registers all API routes on router. Called by initRoutes and tests. Routes that require the db are replaced with 501 not implemented.

func ServeRoutes

func ServeRoutes(cfg *config.APIConfigSpec) error

ServeRoutes generates an HTTP router and starts listening! Requires the config to be loaded.

Types

This section is empty.

Directories

Path Synopsis
Package graphs contains routes that generate html/js graphs that can be embedded into other pages.
Package graphs contains routes that generate html/js graphs that can be embedded into other pages.
Package misc contains routes that don't belong in other categories.
Package misc contains routes that don't belong in other categories.
Package scoring contains all the routes involving scorechecks.
Package scoring contains all the routes involving scorechecks.
Package users contains all the API routes involving scoring users.
Package users contains all the API routes involving scoring users.

Jump to

Keyboard shortcuts

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