ssr

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Addon

func Addon() gowdk.Addon

Addon enables request-time full-page rendering.

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 Register

func Register(router Router, routes []Route)

Register adds generated SSR routes to a router.

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

type GuardRegistry map[string]GuardFunc

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

type LoadContext struct {
	Context context.Context
	Request *http.Request
	Session map[string]any
}

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 Route

type Route struct {
	Pattern string
	Handler http.Handler
}

Route is one generated SSR route binding.

type Router

type Router interface {
	Handle(pattern string, handler http.Handler)
}

Router registers generated SSR page handlers.

Jump to

Keyboard shortcuts

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