server

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package server implements the local development HTTP server with live reload.

Index

Constants

This section is empty.

Variables

View Source
var WatchDirs = []string{"content", "themes", "assets"}

WatchDirs is the set of directories monitored for changes.

Functions

This section is empty.

Types

type DevServer

type DevServer struct {
	Host        string
	Port        int
	OutDir      string
	RootDir     string // project root; WatchDirs are resolved relative to this when set
	Watcher     FileWatcher
	RebuildFunc func() error // called on file change; may be nil
}

DevServer is a local HTTP development server with live reload.

func NewDevServer

func NewDevServer(host string, port int, outDir string, rebuildFn func() error) *DevServer

NewDevServer creates a new DevServer. rebuildFn is called when a watched file changes; pass nil to disable rebuild.

func (*DevServer) Start

func (s *DevServer) Start() error

Start starts the development server and blocks until it exits.

type FileWatcher

type FileWatcher interface {
	Add(path string) error
	Events() <-chan string
	Close() error
}

FileWatcher is the file change detection interface. The implementation uses fsnotify.

type FsnotifyWatcher

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

FsnotifyWatcher implements FileWatcher using github.com/fsnotify/fsnotify.

func NewFsnotifyWatcher

func NewFsnotifyWatcher() (*FsnotifyWatcher, error)

NewFsnotifyWatcher creates and starts a new FsnotifyWatcher.

func (*FsnotifyWatcher) Add

func (fw *FsnotifyWatcher) Add(path string) error

Add adds a path to be watched.

func (*FsnotifyWatcher) Close

func (fw *FsnotifyWatcher) Close() error

Close stops the watcher.

func (*FsnotifyWatcher) Events

func (fw *FsnotifyWatcher) Events() <-chan string

Events returns the channel that receives changed file paths.

Jump to

Keyboard shortcuts

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