extractor

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeEchoPath

func NormalizeEchoPath(path string) string

NormalizeEchoPath converts Echo-style :param segments to {param}.

func NormalizeFiberPath

func NormalizeFiberPath(path string) string

NormalizeFiberPath converts Fiber-style :param and :param? to {param}, * to {wildcard}.

func NormalizeGorillaPath

func NormalizeGorillaPath(path string) string

normalizeGorillaPath converts {id:[0-9]+} → {id}. NormalizeGorillaPath strips regex constraints from gorilla path parameters. e.g. "/items/{id:[0-9]+}" → "/items/{id}"

Types

type ChiExtractor

type ChiExtractor struct{}

ChiExtractor extracts routes from go-chi/chi router registrations.

func (*ChiExtractor) Extract

func (e *ChiExtractor) Extract(pkgs []*packages.Package) ([]RawRoute, error)

Extract walks all packages and extracts chi route registrations.

type EchoExtractor

type EchoExtractor struct{}

EchoExtractor extracts routes from Echo v4 router registrations.

func (*EchoExtractor) Extract

func (e *EchoExtractor) Extract(pkgs []*packages.Package) ([]RawRoute, error)

Extract walks all packages and extracts Echo route registrations.

type Extractor

type Extractor interface {
	Extract(pkgs []*packages.Package) ([]RawRoute, error)
}

Extractor discovers HTTP route registrations from parsed Go packages. Each router framework (chi, gin) has its own implementation.

type FiberExtractor

type FiberExtractor struct{}

FiberExtractor extracts routes from gofiber/fiber/v2 router registrations.

func (*FiberExtractor) Extract

func (e *FiberExtractor) Extract(pkgs []*packages.Package) ([]RawRoute, error)

Extract walks all packages and extracts Fiber route registrations.

type GinExtractor

type GinExtractor struct{}

GinExtractor extracts routes from gin-gonic/gin router registrations.

func (*GinExtractor) Extract

func (e *GinExtractor) Extract(pkgs []*packages.Package) ([]RawRoute, error)

Extract walks all packages and extracts gin route registrations.

type GorillaExtractor

type GorillaExtractor struct{}

GorillaExtractor extracts routes from gorilla/mux router registrations.

func (*GorillaExtractor) Extract

func (e *GorillaExtractor) Extract(pkgs []*packages.Package) ([]RawRoute, error)

Extract walks all packages and extracts gorilla/mux route registrations.

type RawRoute

type RawRoute struct {
	Method      string     // GET, POST, PUT, DELETE, PATCH
	Path        string     // Normalized path with {param} format
	HandlerExpr ast.Expr   // The AST expression referencing the handler function
	Middlewares []ast.Expr // Middleware expressions applied to this route
	File        string     // Source file where this route was registered
	Line        int        // Line number of the route registration
}

RawRoute represents a single HTTP route extracted from the AST before handler resolution and contract analysis. This is the output of the route extraction phase — router-agnostic after normalization.

type StdlibExtractor

type StdlibExtractor struct{}

StdlibExtractor extracts routes from net/http ServeMux registrations. Supports Go 1.22+ enhanced patterns ("GET /path/{id}") and pre-1.22 patterns.

func (*StdlibExtractor) Extract

func (e *StdlibExtractor) Extract(pkgs []*packages.Package) ([]RawRoute, error)

Extract walks all packages and extracts stdlib route registrations.

Jump to

Keyboard shortcuts

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