api-graph

command
v14.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

The apigraph controller: an interactive D3.js map of every registered route, mounted behind an admin guard.

The graph shows paths, methods, handler names and editor links to each handler's source line. It is generated after the application builds, so the mount order relative to the routes it draws does not matter.

Mount it behind an admin guard, and preferably in development builds only: it exposes the whole API surface plus local source file paths. The guard below compares the X-Admin-Token request header against the ADMIN_TOKEN environment variable ("dev" when unset).

Learn: draw your route table as a page you can click through, and keep it behind a token. Before: ../multi-app

Run:

go run main.go

The page loads d3.js from the network, so open it in a browser with the token header set, or read the HTML with curl.

Try:

curl -i http://localhost:8080/admin/apigraph                       # 401, no token
curl -H "X-Admin-Token: dev" http://localhost:8080/admin/apigraph   # 200, the graph page

Next: ../sitemap

Jump to

Keyboard shortcuts

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