router is an explicit, immutable HTTP router built on Go's net/http
programming model. It adds deterministic composition, groups, names, safe URL
generation, metadata, introspection, mounts, and route-scoped middleware while
keeping handlers as ordinary http.Handler values.
The minimum supported toolchain is Go 1.26.6. The package has no runtime dependencies and no global router, reflection discovery, controller resolver, container, session, template, or application lifecycle.
See the versioned Golib ecosystem index and its service-edge package guidance for the shared design language and related packages.
builder := router.New()
err := builder.Register(router.Route{
Name: "users.show",
Methods: []string{http.MethodGet},
Path: "/users/{id}",
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, r.PathValue("id"))
}),
})
if err != nil {
return err
}
handler, err := builder.Compile()
if err != nil {
return err
}
return http.ListenAndServe(":8080", handler)Registration is single-owner and startup-time. The compiled router is an
immutable http.Handler safe for concurrent serving and introspection.
- Semantics
- Specification decisions
- Pinned conformance matrix
- Compatibility
- Behavior matrices
- Resource limits
- Security
- Architecture
- Five-minute quickstarts
- API reference
- Adoption guides
- Migration guides
- Cookbook
- Performance
- FAQ
- Troubleshooting
- Release process
Run make check for the blocking local checks. NilAway remains visible as an
advisory result in the shared contract. Each target is independently
reproducible.
Run make cohesion to validate this module's catalog classification,
ownership contract, documentation entry points, and ecosystem navigation.
Run make ci for the complete local contract, including online specification
source validation.
Use the documentation index for package-owned guides, operational contracts, examples, and maintainer references.