serve

package
v0.0.0-...-594b616 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package serve implements a local development server with live-reload, similar to VS Code's Live Server extension.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	Root    string // root directory to serve files from
	Port    int    // port to listen on
	Host    string // host to bind to
	Entry   string // entry HTML file (e.g. "index.html")
	NoOpen  bool   // if true, don't auto-open in browser
	Verbose bool   // print request logs
	// contains filtered or unexported fields
}

Server is a local HTTP file server with live-reload via WebSocket.

func New

func New(root, entry string, port int) *Server

New creates a new Server with sensible defaults.

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTP server and file watcher.

func (*Server) Stop

func (s *Server) Stop()

Stop stops the file watcher and cleans up.

type Watcher

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

Watcher watches a directory tree for file changes and calls a callback.

func NewWatcher

func NewWatcher(root string, callback func(path string)) (*Watcher, error)

NewWatcher creates a new file watcher for the given root directory.

func (*Watcher) Close

func (w *Watcher) Close()

Close stops the watcher.

Jump to

Keyboard shortcuts

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