Documentation
¶
Index ¶
- func Generate(tree *RouteTree, pkgName string) ([]byte, error)
- func GenerateAssetsFile(entries []AssetEntry, pkgName string) ([]byte, error)
- func GenerateRouteFile(pkgName string) ([]byte, error)
- func LoadPackages(dir, pattern string) ([]*packages.Package, error)
- type AssetEntry
- type AssetGroup
- type PathParam
- type RouteEntry
- type RouteGroup
- type RouteTree
- type StructField
- type StructInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate produces the generated Go source file containing type-safe route constructors and asset accessors from the given RouteTree.
func GenerateAssetsFile ¶
func GenerateAssetsFile(entries []AssetEntry, pkgName string) ([]byte, error)
GenerateAssetsFile generates a Go source file with functions for each asset.
func GenerateRouteFile ¶
GenerateRouteFile generates the route.go file containing the Route type and helper functions used by the generated route constructors.
Types ¶
type AssetEntry ¶
type AssetEntry struct {
// FilePath is the URL path (e.g. "/assets/app.js").
FilePath string
// FuncName is the Go function name (e.g. "AppJs").
FuncName string
// Hash is the truncated content hash for cache busting.
Hash string
}
AssetEntry represents a static file with its path and content hash.
func ScanAssets ¶
func ScanAssets(dir string, urlPrefix string) ([]AssetEntry, error)
ScanAssets scans a directory and returns asset entries with content hashes.
type AssetGroup ¶
type AssetGroup struct {
Name string // derived from the FS variable name (e.g. "publicFS" → "PublicFS")
Prefix string
Dir string // absolute path to the directory on disk
Entries []AssetEntry
}
AssetGroup represents a set of static assets served from one directory.
type PathParam ¶
type PathParam struct {
Name string
}
PathParam represents a named path parameter extracted from a route pattern.
type RouteEntry ¶
type RouteEntry struct {
Name string
Method string
Path string
PathParams []PathParam
QueryType *StructInfo
}
RouteEntry represents a single route with its HTTP method and path.
type RouteGroup ¶
type RouteGroup struct {
Name string
Prefix string
Routes []RouteEntry
Groups []RouteGroup
}
RouteGroup represents a group of routes under a common URL prefix.
type RouteTree ¶
type RouteTree struct {
Routes []RouteEntry
Groups []RouteGroup
Assets []AssetGroup
}
RouteTree is the top-level structure holding all extracted route information.
type StructField ¶
StructField represents a single field in a query parameter struct.
type StructInfo ¶
type StructInfo struct {
Fields []StructField
}
StructInfo holds metadata about a query parameter struct's fields.