webserver

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultGames = []GameEntry{
	{Name: "Stardew Valley", Port: 24642},
	{Name: "Terraria", Port: 7777},
	{Name: "Factorio", Port: 34197},
	{Name: "Minecraft (Bedrock)", Port: 19132},
	{Name: "Valheim", Port: 2456},
}

DefaultGames is the list of known games shown in the host form dropdown.

Functions

func NewRouter added in v0.2.0

func NewRouter(s *Server) *http.ServeMux

NewRouter creates an http.ServeMux with all web UI routes registered.

Types

type GameEntry

type GameEntry struct {
	Name string
	Port int
}

GameEntry represents a known game with its default port.

type SSEHandler added in v0.2.0

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

SSEHandler is a slog.Handler that broadcasts log lines to SSE subscribers. It also maintains a ring buffer for history replay on new connections.

func NewSSEHandler added in v0.2.0

func NewSSEHandler(bufferSize int) *SSEHandler

NewSSEHandler creates a new SSE log handler with the given buffer size.

func (*SSEHandler) Enabled added in v0.2.0

func (h *SSEHandler) Enabled(context.Context, slog.Level) bool

func (*SSEHandler) Handle added in v0.2.0

func (h *SSEHandler) Handle(ctx context.Context, r slog.Record) error

func (*SSEHandler) Reset added in v0.2.0

func (h *SSEHandler) Reset()

Reset clears the buffer and disconnects all subscribers.

func (*SSEHandler) Subscribe added in v0.2.0

func (h *SSEHandler) Subscribe() ([]string, chan string)

Subscribe returns buffered history and a channel for new log lines.

func (*SSEHandler) Unsubscribe added in v0.2.0

func (h *SSEHandler) Unsubscribe(ch chan string)

Unsubscribe removes a subscriber channel.

func (*SSEHandler) WithAttrs added in v0.2.0

func (h *SSEHandler) WithAttrs([]slog.Attr) slog.Handler

func (*SSEHandler) WithGroup added in v0.2.0

func (h *SSEHandler) WithGroup(string) slog.Handler

type Server added in v0.2.0

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

Server is the web UI HTTP server.

func New

func New() (*Server, error)

New creates a new Server and registers all routes.

func (*Server) Stop added in v0.2.0

func (s *Server) Stop()

Stop gracefully stops any active session and waits for all background goroutines to finish.

Jump to

Keyboard shortcuts

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