Documentation
¶
Overview ¶
Package routedump is the wire format between a Nucleus application that prints its route table at boot (NUCLEUS_PRINT_ROUTES=1, read by pkg/nucleus.RunContext) and the `nucleus routes` command that runs the application to read it. Both sides import this package so the document shape, the environment variable and the line marker cannot drift apart.
The document travels on the application's stdout, where the structured logger also writes, so it is emitted as ONE line carrying a schema marker that no log line can start with; Parse scans stdout for that line and ignores everything else.
Index ¶
Constants ¶
const EnvVar = "NUCLEUS_PRINT_ROUTES"
EnvVar is the environment variable the application reads at boot. Any value other than empty, "0" or "false" turns the dump on.
const Schema = "nucleus.routes/v1"
Schema identifies the document version; it doubles as the line marker Parse looks for.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Document ¶
type Document struct {
Schema string `json:"schema"`
Env string `json:"env"`
Routes []Route `json:"routes"`
}
Document is what the application prints.
type Route ¶
type Route struct {
// Method is the HTTP method, or "*" when the entry answers every method
// (a mounted subtree or a method-less Handle).
Method string `json:"method"`
// Pattern is the full request path pattern, module prefix applied.
Pattern string `json:"pattern"`
// Module names the module that registered the route; empty for the
// framework's own routes.
Module string `json:"module,omitempty"`
// Middlewares counts the middleware wrapped around the entry at
// registration time.
Middlewares int `json:"middlewares"`
}
Route is one entry of the application's route table.