Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateClientStubs ¶
func GenerateClientStubs(functions []ServerFunction, moduleName string) (string, error)
GenerateClientStubs generates WASM-side client stubs for server functions. The generated code has a //go:build js && wasm build tag and calls golem.CallServerFunction to invoke server functions via HTTP/JSON.
func GenerateRoutes ¶
func GenerateRoutes(tree *ScannedRoute, moduleName string) (string, error)
GenerateRoutes takes a scanned route tree and module name, returns generated Go source code.
Types ¶
type FuncReturn ¶
FuncReturn represents a function return value
type ScannedRoute ¶
type ScannedRoute struct {
Path string // URL path pattern (e.g., "/blog/:slug")
Segment string // directory name
DirPath string // absolute filesystem path to directory
PageFile string // path to page.go (if exists)
LayoutFile string // path to layout.go (if exists)
ErrorFile string // path to error.go (if exists)
LoadingFile string // path to loading.go (if exists)
NotFoundFile string // path to notfound.go (if exists)
TemplateFile string // path to template.go (if exists)
Children []*ScannedRoute
ParamName string // for [slug] -> "slug"
IsCatchAll bool // for [...path]
IsOptionalCatchAll bool // for [[...path]]
IsGroup bool // for (marketing) -- not in URL
GroupName string // "marketing" for (marketing)
ParallelSlots map[string]*ScannedRoute // for @sidebar -> "sidebar"
InterceptPattern string // "(.)", "(..)", "(...)"
InterceptDepth int // 0=same level, 1=parent, -1=root
}
ScannedRoute represents a discovered route from the filesystem
func ScanRoutes ¶
func ScanRoutes(appDir string) (*ScannedRoute, error)
ScanRoutes scans the app directory and returns a route tree
type ServerFunction ¶
type ServerFunction struct {
Name string
Package string
Params []FuncParam
Returns []FuncReturn
FilePath string
}
ServerFunction represents a discovered server function
func DiscoverServerFunctions ¶
func DiscoverServerFunctions(serverDir string) ([]ServerFunction, error)
DiscoverServerFunctions scans a directory for exported Go functions. It walks the directory looking for .go files, parses each with go/parser, finds exported functions (capitalized names), and extracts parameter names/types and return types. It skips init(), main(), test functions, and _test.go files.