Documentation
¶
Index ¶
- Constants
- func Addon() gowdk.Addon
- func ComposeLayouts(ctx LoadContext, stack LayoutStack, registry LayoutRegistry, body string) (string, error)
- func DefaultErrorHandler(w http.ResponseWriter, r *http.Request, err error)
- func LoadPath(data map[string]any, path string) (any, bool)
- func Redirect(url string, status int) error
- func RedirectTarget(err error) (string, int, bool)
- func RedirectTo(url string) error
- func Register(router Router, routes []Route)
- func RunGuards(ctx LoadContext, names []string, registry GuardRegistry) error
- type ErrorHandler
- type GuardFunc
- type GuardRegistry
- type LayoutFunc
- type LayoutRegistry
- type LayoutStack
- type LoadContext
- type LoadFunc
- type RedirectError
- type Route
- type Router
Constants ¶
const ImportPath = "github.com/cssbruno/gowdk/addons/ssr"
ImportPath is the canonical Go import path for the SSR addon.
Variables ¶
This section is empty.
Functions ¶
func ComposeLayouts ¶
func ComposeLayouts(ctx LoadContext, stack LayoutStack, registry LayoutRegistry, body string) (string, error)
ComposeLayouts wraps body with the declared layout stack. Layouts are listed from outermost to innermost, matching @layout root, dashboard semantics.
func DefaultErrorHandler ¶
func DefaultErrorHandler(w http.ResponseWriter, r *http.Request, err error)
DefaultErrorHandler renders a conservative SSR failure response.
func LoadPath ¶ added in v0.1.5
LoadPath resolves a declared load {} path from generated SSR load data. Supported values are nested maps with string keys, structs, pointers, and interfaces. Struct fields may be matched by exported Go field name or json tag.
func Redirect ¶ added in v0.1.5
Redirect returns an error that generated SSR handlers translate into a no-store local redirect with the provided 3xx status.
func RedirectTarget ¶ added in v0.1.5
RedirectTarget extracts a generated SSR redirect error.
func RedirectTo ¶ added in v0.1.5
RedirectTo returns an error that generated SSR handlers translate into a no-store local redirect.
func RunGuards ¶
func RunGuards(ctx LoadContext, names []string, registry GuardRegistry) error
RunGuards executes guard IDs in declaration order.
Types ¶
type ErrorHandler ¶
type ErrorHandler func(http.ResponseWriter, *http.Request, error)
ErrorHandler renders request-time SSR failures.
type GuardFunc ¶
type GuardFunc func(LoadContext) error
GuardFunc authorizes one request-time SSR page access check.
type GuardRegistry ¶
GuardRegistry resolves @guard IDs to executable guard functions.
type LayoutFunc ¶
type LayoutFunc func(LoadContext, string) (string, error)
LayoutFunc wraps already-rendered child HTML with request-aware layout HTML.
type LayoutRegistry ¶
type LayoutRegistry map[string]LayoutFunc
LayoutRegistry maps layout IDs to request-aware layout functions.
type LayoutStack ¶
type LayoutStack []string
LayoutStack is the ordered set of request-time layouts for an SSR page.
type LoadContext ¶
LoadContext is passed to generated request-time load {} functions.
func NewLoadContext ¶
func NewLoadContext(request *http.Request, session map[string]any) LoadContext
NewLoadContext creates the first-slice request context for generated SSR load functions. Session storage is intentionally caller-supplied until the SSR addon defines secure session defaults.
type LoadFunc ¶
type LoadFunc func(LoadContext) (map[string]any, error)
LoadFunc is generated from a request-time load {} block.
type RedirectError ¶ added in v0.1.5
RedirectError asks generated SSR handlers to issue a safe local redirect.
func (RedirectError) Error ¶ added in v0.1.5
func (err RedirectError) Error() string