routescan

package
v1.166.2 Latest Latest
Warning

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

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

Documentation

Overview

Package routescan reads the platform's HTTP route table out of its source: every pattern a Go 1.22 ServeMux registration (Handle, HandleFunc) is given, folded from string literals, package constants and the mount prefixes a registrar's call sites pass. Two gates read it: the admin catalog parity test (every authenticated route is discoverable through the OpenAPI catalog, #697) and the inbound request observer's gate (every route reports its own template, #1889). The two must enumerate the same table, which is why the scan is one package rather than two test files.

A registration whose pattern the scan cannot fold is reported, not skipped: a route the scan cannot see is served and authorized without being checked, which is how 39 routes reached a release undocumented (#1741).

Index

Constants

View Source
const AdminPathPrefixDefault = "/api/v1/admin"

AdminPathPrefixDefault is the admin surface's default mount point, the value pkg/platform writes when admin.path_prefix is unset. admin.path_prefix is operator-configurable, so a registrar mounted there has no single compile-time path; the scan reads those routes at the default because an override moves the whole surface uniformly and changes no route's shape.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	// Routes are the resolved patterns, sorted and deduplicated.
	Routes []Route
	// Unresolved are the positions of mux registrations whose pattern is
	// built from a value the scan cannot fold. A caller fails on them.
	Unresolved []string
}

Result is what a scan found.

func Scan

func Scan(roots ...string) (Result, error)

Scan parses every non-test .go file under roots and returns the route table they register.

func (Result) Patterns

func (r Result) Patterns() []string

Patterns are the resolved patterns alone.

type Route

type Route struct {
	// Pattern is the ServeMux pattern as registered: "GET /api/v1/x/{id}",
	// or "/api/v1/admin/" for a subtree mount with no method.
	Pattern string
	// Pos is the file:line of the registration, for a message.
	Pos string
}

Route is one registered pattern and where it is registered.

Jump to

Keyboard shortcuts

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