api

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package api implements the chi v5 HTTP routes for /api/v1 (SPEC-07) and the OpenAPI 3.1 source-of-truth with a CI route diff.

M1: package skeleton only (this doc.go). M10 lands the routes (health, version, search, explain, validate, assets/{id}[/history], sources, rules, server status/stop), token auth (hashed at rest), scopes, rate-limit headers, request IDs (UUIDv7), standard envelope + API_E_* codes.

The api package depends on internal/search (the SearchService) and internal/config; it never imports any collector or egress package (ADR-0010; AC-3.1 import-graph test).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {

	// TokenHash is the SHA-256 hex digest of the configured API token;
	// "" means token auth is DISABLED — the server must then bind
	// loopback only (enforced by the cmd wiring before ListenAndServe).
	TokenHash string
	// RateLimit is requests per minute per client IP (0 = default 120).
	RateLimit int

	// TrustedProxies are the CIDRs whose X-Forwarded-For header the
	// API may honor for client-IP resolution (M16).  Empty (the
	// default) = peer address only; the header is ignored.
	TrustedProxies []netip.Prefix
	// contains filtered or unexported fields
}

Server is the REST API.

func New

func New(svc *search.Service, tokenHash string, rateLimitPerMin int) *Server

New builds the API Server over the shared SearchService.

func (*Server) Handler

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

Handler builds the http.Handler for the API. Routes live under the /api/v1 prefix (SPEC-07), so the server command mounts this at root.

Jump to

Keyboard shortcuts

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