server

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package server provides the live preview HTTP server. It watches files with fsnotify and pushes reload notifications over WebSocket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// Configuration
	Host      string // Listening host or IP.
	Port      int    // Listening port.
	WatchDir  string // Source directory to watch.
	OutputDir string // Output directory.
	AutoOpen  bool   // Whether to open the browser automatically.

	// BuildFunc is provided by the caller and rebuilds the project output.
	BuildFunc func() error
	// contains filtered or unexported fields
}

Server implements the live preview server.

func NewServer

func NewServer(host string, port int, watchDir, outputDir string, logger *slog.Logger) *Server

NewServer creates a preview server.

func (*Server) Listen

func (s *Server) Listen() (net.Listener, error)

Listen reserves the configured port and returns the listener.

func (*Server) ListenFrom

func (s *Server) ListenFrom(startPort int) (net.Listener, error)

ListenFrom reserves the first available port from startPort upward.

func (*Server) Start

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

Start runs the server until the context is canceled.

func (*Server) StartWithListener

func (s *Server) StartWithListener(ctx context.Context, ln net.Listener) error

StartWithListener runs the server using a pre-bound listener.

Jump to

Keyboard shortcuts

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