routes

package
v1.35.2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsJunkPath added in v1.21.0

func IsJunkPath(path string) bool

IsJunkPath reports whether an extracted route path is too low-quality to be a real HTTP route. It is shared by ingest (codegraph.extractRoutes) and may be used by the coupling verifier for lockstep precision.

Rules (conservative — false-positives cost real routes; false-negatives only allow a few junk survivors):

  1. Contains '?' — a query-string fragment, not a route template. e.g. "/api/leak?c=" from fetch('/api/leak?c='+cookie)

  2. Sole path segment matches a known HTTP header name (case-insensitive). e.g. "/Authorization" from headers.get('Authorization').

  3. Sole path segment is exactly 1 character. e.g. "/A", "/a" from map.get('/A').

  4. Sole path segment is 24+ lowercase/uppercase hex chars (bare token or UUID). e.g. "/a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4".

func NormalizePath

func NormalizePath(raw string) string

NormalizePath normalizes a route path:

  • Strips URL scheme and host (if the path contains "://")
  • Ensures a leading slash
  • Replaces path parameters (:id, {id}) with *
  • Cleans double slashes

func Register

func Register(m RouteMatcher)

Register adds a matcher to the global registry.

Types

type CSharpMatcher

type CSharpMatcher struct{}

CSharpMatcher extracts HTTP routes from C# source code (ASP.NET).

func (*CSharpMatcher) Language

func (cs *CSharpMatcher) Language() string

Language returns the language identifier for this matcher.

func (*CSharpMatcher) Match

func (cs *CSharpMatcher) Match(source []byte) []Route

Match scans C# source and returns all detected routes. Each returned Route has its Line field set to the 1-based line number of the match in source — a hard prerequisite for the enclosing-function resolver.

type GoMatcher

type GoMatcher struct{}

GoMatcher extracts HTTP routes from Go source code.

func (*GoMatcher) Language

func (g *GoMatcher) Language() string

Language returns the language identifier for this matcher.

func (*GoMatcher) Match

func (g *GoMatcher) Match(source []byte) []Route

Match scans Go source code and returns all detected routes. Each returned Route has its Line field set to the 1-based line number of the match in source — a hard prerequisite for the enclosing-function resolver.

type HTMLMatcher added in v1.20.0

type HTMLMatcher struct{}

HTMLMatcher extracts htmx HTTP routes from HTML/Go-template files. It operates on the ORIGINAL src bytes (not StripGoTemplate output) so that Go template actions embedded in hx-* attribute values are preserved for normalisation by normalizeHtmxPath.

func (*HTMLMatcher) Language added in v1.20.0

func (h *HTMLMatcher) Language() string

Language returns the language identifier for this matcher.

func (*HTMLMatcher) Match added in v1.20.0

func (h *HTMLMatcher) Match(source []byte) []Route

Match scans HTML source for htmx URL-emitting attributes and returns client-side routes with Side="client" and Framework="htmx".

type JavaMatcher

type JavaMatcher struct{}

JavaMatcher extracts HTTP routes from Java source code (Spring).

func (*JavaMatcher) Language

func (j *JavaMatcher) Language() string

Language returns the language identifier for this matcher.

func (*JavaMatcher) Match

func (j *JavaMatcher) Match(source []byte) []Route

Match scans Java source and returns all detected routes. Each returned Route has its Line field set to the 1-based line number of the match in source — a hard prerequisite for the enclosing-function resolver.

type PHPHookMatcher

type PHPHookMatcher struct{}

PHPHookMatcher extracts WordPress hook registrations and invocations from PHP source code as Route entries.

Hook registrations (add_action/add_filter) map to server-side routes. Hook invocations (do_action/apply_filters) map to client-side routes.

func (*PHPHookMatcher) Language

func (m *PHPHookMatcher) Language() string

Language returns the language identifier for this matcher.

func (*PHPHookMatcher) Match

func (m *PHPHookMatcher) Match(source []byte) []Route

Match scans PHP source code and returns all detected WordPress hook routes.

type PythonMatcher

type PythonMatcher struct{}

PythonMatcher extracts HTTP routes from Python source code.

func (*PythonMatcher) Language

func (p *PythonMatcher) Language() string

Language returns the language identifier for this matcher.

func (*PythonMatcher) Match

func (p *PythonMatcher) Match(source []byte) []Route

Match scans Python source and returns all detected routes. Each returned Route has its Line field set to the 1-based line number of the match in source — a hard prerequisite for the enclosing-function resolver.

type Route

type Route struct {
	Method    string // "GET", "POST", "*"
	Path      string // normalized path
	RawPath   string // original path from source
	Handler   string // symbol name
	Framework string // "net/http", "chi", "express", etc.
	File      string
	Line      uint32
	Side      string // "server" or "client"
}

Route represents an HTTP route extracted from source code.

func ExtractAll

func ExtractAll(language string, source []byte) []Route

ExtractAll runs all registered matchers for the given language and returns the combined set of discovered routes.

type RouteMatcher

type RouteMatcher interface {
	Language() string
	Match(source []byte) []Route
}

RouteMatcher extracts routes from source code for a specific language.

type RubyMatcher

type RubyMatcher struct{}

RubyMatcher extracts HTTP routes from Ruby source code (Sinatra, Rails).

func (*RubyMatcher) Language

func (rb *RubyMatcher) Language() string

Language returns the language identifier for this matcher.

func (*RubyMatcher) Match

func (rb *RubyMatcher) Match(source []byte) []Route

Match scans Ruby source and returns all detected routes. Each returned Route has its Line field set to the 1-based line number of the match in source — a hard prerequisite for the enclosing-function resolver.

type RustMatcher

type RustMatcher struct{}

RustMatcher extracts HTTP routes from Rust source code. Supported frameworks:

  • Actix-web / Rocket: attribute macros (#[get("/path")], #[post("/path")], etc.)
  • Actix-web: builder pattern (.route("/path", web::get()))
  • Axum: builder pattern (.route("/path", get(handler)), .route("/path", any(handler)))

acme-edge (acme-edge) uses axum 0.8 exclusively; adding the axum matcher resolves the Route=0 gap observed in its AGE graph (FU-CG.5).

func (*RustMatcher) Language

func (r *RustMatcher) Language() string

Language returns the language identifier for this matcher.

func (*RustMatcher) Match

func (r *RustMatcher) Match(source []byte) []Route

Match scans Rust source and returns all detected routes. Each returned Route has its Line field set to the 1-based source line number, a hard prerequisite for the CG-T3 enclosing-function resolver.

type TypeScriptMatcher

type TypeScriptMatcher struct{}

TypeScriptMatcher extracts HTTP routes from TypeScript and JavaScript source code.

func (*TypeScriptMatcher) Language

func (ts *TypeScriptMatcher) Language() string

Language returns the language identifier for this matcher.

func (*TypeScriptMatcher) Match

func (ts *TypeScriptMatcher) Match(source []byte) []Route

Match scans TypeScript/JavaScript source and returns all detected routes. Each returned Route has its Line field set to the 1-based line number of the match in source — a hard prerequisite for the enclosing-function resolver.

Jump to

Keyboard shortcuts

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