Documentation
¶
Index ¶
- func Mount(mux *http.ServeMux) error
- func RegisterHandlers(handlers ...any) error
- func Render(mux *http.ServeMux) error
- func Serve(addr string) error
- func SetAccessCheck(fn func(resource string, action byte, data ...any) bool)
- func SetCacheSize(size int)
- func SetDefaultRoute(route string)
- func SetDevMode(enabled bool)
- func SetOutputDir(dir string)
- func SetUserRoles(fn func(data ...any) []byte)
- type CSSProvider
- type Config
- type IconSvgProvider
- type JSProvider
- type Module
- type ModuleLifecycle
- type Parameterized
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Mount ¶ added in v0.0.5
Mount registers the site handlers with the provided mux and prepares assets.
func RegisterHandlers ¶
RegisterHandlers registers all handlers with site and crudp
func Render ¶ added in v0.0.17
Render registers the site handlers with the provided mux and prepares assets. DEPRECATED: Use Mount(mux) instead.
func Serve ¶ added in v0.0.17
Serve starts the server on the given address (one-liner helper). It creates a new ServeMux, mounts the site, and listens on the address.
func SetAccessCheck ¶ added in v0.0.45
SetAccessCheck configures an external access check function. When set, AllowedRoles() interface is NOT required on handlers. Must be called before RegisterModules().
Integration with rbac:
site.SetAccessCheck(func(resource string, action byte, data ...any) bool {
for _, d := range data {
if req, ok := d.(*http.Request); ok {
userID := req.Header.Get("X-User-ID")
ok, _ := rbac.HasPermission(userID, resource, action)
return ok
}
}
return false
})
func SetCacheSize ¶ added in v0.0.17
func SetCacheSize(size int)
SetCacheSize configures module cache size (default: 3)
func SetDefaultRoute ¶ added in v0.0.17
func SetDefaultRoute(route string)
SetDefaultRoute configures default route (default: "home")
func SetDevMode ¶ added in v0.0.17
func SetDevMode(enabled bool)
SetDevMode configures development mode (default: false)
func SetOutputDir ¶ added in v0.0.17
func SetOutputDir(dir string)
SetOutputDir configures the output directory for assets (default: "./public")
func SetUserRoles ¶ added in v0.0.16
SetUserRoles configures the function to extract user roles from the request context.
Types ¶
type CSSProvider ¶ added in v0.0.45
type CSSProvider interface {
RenderCSS() string
}
CSSProvider interface for components that provide CSS
type IconSvgProvider ¶ added in v0.0.45
IconSvgProvider interface for components that provide SVG icons
type JSProvider ¶ added in v0.0.45
type JSProvider interface {
RenderJS() string
}
JSProvider interface for components that provide JS
type Module ¶ added in v0.0.17
Module represents a top-level site module. It combines a DOM component with site-specific identifiers.
type ModuleLifecycle ¶ added in v0.0.17
type ModuleLifecycle interface {
}
ModuleLifecycle provides hooks for navigation events
type Parameterized ¶ added in v0.0.17
type Parameterized interface {
SetParams(params []string)
}
Parameterized modules can receive route parameters