go_ssr

package module
v0.0.0-...-8ddeac0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	AppEnv              string            // "production" or "development"
	AssetRoute          string            // The route to serve assets from, e.g. "/assets"
	FrontendDir         string            // The path to the frontend folder, where your React app lives
	GeneratedTypesPath  string            // The path to the generated types file
	PropsStructsPath    string            // The path to the Go structs file, the structs will be generated to TS types
	LayoutFilePath      string            // The path to the layout file, relative to the frontend dir
	LayoutCSSFilePath   string            // The path to the layout css file, relative to the frontend dir
	TailwindConfigPath  string            // The path to the tailwind config file
	HotReloadServerPort int               // The port to run the hot reload server on, 3001 by default
	JSRuntimePoolSize   int               // The number of JS runtimes to keep in the pool, 10 by default
	CacheConfig         cache.CacheConfig // Cache configuration (local or redis)
	ClientAppPath       string            // Path to client SPA app (e.g., "App.tsx") for client-side routing after hydration
}

Config is the config for starting the engine

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the config

type Engine

type Engine struct {
	Logger                  *slog.Logger
	Config                  *Config
	HotReload               *HotReload
	Cache                   cache.Cache
	RuntimePool             *jsruntime.Pool
	CachedLayoutCSSFilePath string
	CachedClientSPAJS       string // Cached client SPA bundle JS
}

func New

func New(config Config) (*Engine, error)

New creates a new gossr Engine instance

func (*Engine) BuildLayoutCSSFile

func (engine *Engine) BuildLayoutCSSFile() error

BuildLayoutCSSFile builds the layout css file if it exists

func (*Engine) IsProduction

func (engine *Engine) IsProduction() bool

IsProduction returns true if running in production mode

func (*Engine) RenderRoute

func (engine *Engine) RenderRoute(renderConfig RenderConfig) []byte

RenderRoute renders a route to html

func (*Engine) Shutdown

func (engine *Engine) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the engine and releases all resources. It should be called when the server is shutting down. The context can be used to set a timeout for the shutdown.

type HotReload

type HotReload struct {
	// contains filtered or unexported fields
}

func (*HotReload) Start

func (hr *HotReload) Start()

Start starts the hot reload server and watcher

type RenderConfig

type RenderConfig struct {
	File     string
	Title    string
	MetaTags map[string]string
	Props    interface{}
}

RenderConfig is the config for rendering a route

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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