server

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package server provides the HTTP server and WebSocket handler for the web interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpgradeConnection

func UpgradeConnection(w http.ResponseWriter, r *http.Request) (*websocket.Conn, error)

UpgradeConnection upgrades an HTTP connection to WebSocket.

Types

type CommandHandler

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

CommandHandler processes WebSocket commands.

func NewCommandHandler

func NewCommandHandler(
	cfg *config.Config,
	getState func() types.EncoderState,
	startOutput func(string) error,
	stopOutput func(string) error,
	restartEnc func() error,
	testTriggers map[string]func() error,
) *CommandHandler

NewCommandHandler creates a new command handler.

func (*CommandHandler) Handle

func (h *CommandHandler) Handle(cmd WSCommand, conn *websocket.Conn, triggerStatusUpdate func())

Handle processes a WebSocket command and performs the requested action.

type SessionManager

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

SessionManager handles user authentication sessions.

func NewSessionManager

func NewSessionManager() *SessionManager

NewSessionManager creates a new session manager.

func (*SessionManager) AuthMiddleware

func (sm *SessionManager) AuthMiddleware(username, password string) func(http.HandlerFunc) http.HandlerFunc

AuthMiddleware returns middleware that requires HTTP Basic Authentication or a valid session cookie.

func (*SessionManager) Create

func (sm *SessionManager) Create() string

Create creates a new session and returns the token.

func (*SessionManager) Validate

func (sm *SessionManager) Validate(token string) bool

Validate checks if a session token is valid.

type WSCommand

type WSCommand struct {
	Type string          `json:"type"`
	ID   string          `json:"id,omitempty"`
	Data json.RawMessage `json:"data,omitempty"`
}

WSCommand is a command received from a WebSocket client.

Jump to

Keyboard shortcuts

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