Documentation
¶
Overview ¶
Package route is the leaf authority for craftgo's HTTP routes: how a method's final route is assembled (base path + @prefix + method path), the string form of a DSL path, the shape key two colliding routes share, and net/http's pattern-overlap rule. The analyzer, the routes/OpenAPI emitters, and the route-conflict detector all read these — one implementation, so the route the editor diagnoses is byte-for-byte the route the generated server mounts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PathString ¶
func PatternsConflict ¶
patternsConflict reports whether two same-verb mux patterns overlap with neither strictly more specific - the exact condition net/http rejects. It models craftgo's single-segment wildcards (`{name}`): patterns of different segment counts can never overlap, and at each shared position a literal beats a wildcard. The pair conflicts when one is more specific at some segment AND the other is more specific at another (a cross-over), or when they are the same pattern (every segment ties) - i.e. neither side wins outright.
func Resolve ¶
ResolveRoute joins the OpenAPI base path, the service's @prefix, and the method's own path into the single absolute route the server registers and the OpenAPI document advertises. Empty segments are dropped, consecutive slashes collapse, the result always begins with '/', and a pathless method falls back to its kebab-cased name ("Ping" → "/ping"). @group is absent on purpose — it nests generated files on disk, never the URL.
This is THE route authority: the analyzer's path checks and every codegen emitter (routes, OpenAPI paths, route-conflict detection) call it, so the route the editor diagnoses is byte-for-byte the route the server mounts.
func ServicePrefix ¶
func ServicePrefix(svc *ast.ServiceDecl) string
decoratorString returns the first string-literal positional arg of `@name(...)` on the service decl, or "" when absent. Used to read `@prefix` and `@group` without depending on codegen helpers.
Types ¶
This section is empty.