server

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hooks

type Hooks interface {
	RegisterRoutes(mux *http.ServeMux)
	OnServerStarted(addr string) error
	OnRoutesAssigned(graph *content.SiteGraph) error
	OnAssetsBuilding(*config.Config) error
}

Hooks exposes the preview-server lifecycle to integrators.

The practical order is:

  1. OnRoutesAssigned during rebuild
  2. RegisterRoutes when the mux is assembled
  3. OnAssetsBuilding during asset sync
  4. OnServerStarted after the listener is ready

type Loader

type Loader interface {
	Load(context.Context) (*content.SiteGraph, error)
}

Loader produces the site graph served by the preview server.

type Option

type Option func(*Server)

Option mutates preview-server construction behavior.

func WithDebugMode

func WithDebugMode(enabled bool) Option

WithDebugMode enables additional debug logging and request instrumentation for the preview server.

type Server

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

Server serves Foundry preview output, rebuilds on change, and exposes preview routes such as live reload and diagnostics.

func New

func New(
	cfg *config.Config,
	loader Loader,
	router *router.Resolver,
	renderer *renderer.Renderer,
	hooks Hooks,
	preview bool,
	opts ...Option,
) *Server

New constructs a preview server for the current configuration, graph loader, resolver, and renderer.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context) error

ListenAndServe performs the initial rebuild, starts file watching, and serves preview traffic until ctx is canceled or the HTTP server exits.

Jump to

Keyboard shortcuts

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