http

package
v0.0.0-...-34e04b6 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultShutdownTimeout is the maximum time to wait for active connections
	// to complete during graceful shutdown. 5 seconds allows most in-flight requests
	// to complete while preventing indefinite hangs during shutdown.
	DefaultShutdownTimeout = 5 * time.Second
)

Variables

This section is empty.

Functions

func NewHTTPLogger

func NewHTTPLogger(component string, verbose bool) *logging.Logger

NewHTTPLogger creates a new HTTP logger instance using the shared logging package. HTTP server loggers always log Info messages (don't require verbose=true).

func NewHTTPLoggerWithLevel

func NewHTTPLoggerWithLevel(component string, verbose bool, level entities.LogLevel) *logging.Logger

NewHTTPLoggerWithLevel creates a new HTTP logger instance with specific level. HTTP server loggers always log Info messages (don't require verbose=true).

Types

type ClientMessage

type ClientMessage struct {
	Type string                 `json:"type"`
	Data map[string]interface{} `json:"data"`
}

ClientMessage represents a message received from the client

type ClientMode

type ClientMode string

ClientMode represents the type of WebSocket client

const (
	ClientModeAudience  ClientMode = "audience"
	ClientModePresenter ClientMode = "presenter"
)

type ConfigResponse

type ConfigResponse struct {
	Version         string   `json:"version"`
	Theme           string   `json:"theme"`
	WebSocketURL    string   `json:"websocket_url"`
	LiveReload      bool     `json:"live_reload"`
	SupportedThemes []string `json:"supported_themes"`
}

ConfigResponse represents the configuration API response

type Connection

type Connection struct {
	ID   string
	Send chan ports.UpdateEvent
	// contains filtered or unexported fields
}

Connection represents a WebSocket connection

func (*Connection) Close

func (c *Connection) Close()

Close safely closes the connection's send channel exactly once. It is safe to call this method multiple times.

type ConnectionManager

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

ConnectionManager manages WebSocket connections

func NewConnectionManager

func NewConnectionManager() *ConnectionManager

NewConnectionManager creates a new connection manager

func (*ConnectionManager) Broadcast

func (cm *ConnectionManager) Broadcast(event ports.UpdateEvent)

Broadcast sends an event to all connections. If the broadcast channel is full and cannot accept the event within broadcastTimeout, the event is dropped and a warning is logged.

func (*ConnectionManager) CloseAll

func (cm *ConnectionManager) CloseAll()

CloseAll closes all connections

func (*ConnectionManager) RegisterConnection

func (cm *ConnectionManager) RegisterConnection(conn *Connection)

RegisterConnection adds a new connection directly

func (*ConnectionManager) Run

func (cm *ConnectionManager) Run(ctx context.Context)

Run starts the connection manager main loop

func (*ConnectionManager) Unregister

func (cm *ConnectionManager) Unregister(connID string)

Unregister removes a connection

type ErrorResponse

type ErrorResponse struct {
	Error   string    `json:"error"`
	Message string    `json:"message"`
	Time    time.Time `json:"time"`
}

ErrorResponse represents an error response

type PresenterHandler

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

PresenterHandler handles presenter mode requests

func NewPresenterHandler

func NewPresenterHandler(sync ports.PresentationSync) *PresenterHandler

NewPresenterHandler creates a new presenter handler Deprecated: Use NewPresenterHandlerWithConfig instead for proper origin validation

func NewPresenterHandlerFull

func NewPresenterHandlerFull(sync ports.PresentationSync, config *entities.ServerConfig, loggingConfig *entities.LoggingConfig) *PresenterHandler

NewPresenterHandlerFull creates a new presenter handler with full configuration

func NewPresenterHandlerWithConfig

func NewPresenterHandlerWithConfig(sync ports.PresentationSync, config *entities.ServerConfig) *PresenterHandler

NewPresenterHandlerWithConfig creates a new presenter handler with server config for origin validation

func NewPresenterHandlerWithLogging

func NewPresenterHandlerWithLogging(sync ports.PresentationSync, loggingConfig *entities.LoggingConfig) *PresenterHandler

NewPresenterHandlerWithLogging creates a new presenter handler with logging configuration Deprecated: Use NewPresenterHandlerFull instead for proper origin validation

func (*PresenterHandler) HandleNavigation

func (h *PresenterHandler) HandleNavigation(w http.ResponseWriter, r *http.Request)

HandleNavigation handles navigation requests

func (*PresenterHandler) HandlePresenterView

func (h *PresenterHandler) HandlePresenterView(w http.ResponseWriter, r *http.Request)

HandlePresenterView serves the presenter mode interface

func (*PresenterHandler) HandleState

func (h *PresenterHandler) HandleState(w http.ResponseWriter, r *http.Request)

HandleState returns the current presenter state

func (*PresenterHandler) HandleTimer

func (h *PresenterHandler) HandleTimer(w http.ResponseWriter, r *http.Request)

HandleTimer handles timer control requests

func (*PresenterHandler) HandleWebSocket

func (h *PresenterHandler) HandleWebSocket(w http.ResponseWriter, r *http.Request)

HandleWebSocket handles WebSocket connections for real-time sync

func (*PresenterHandler) RegisterRoutes

func (h *PresenterHandler) RegisterRoutes(router *mux.Router)

RegisterRoutes registers presenter mode routes

type Server

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

Server implements the HTTPServer interface

func NewServer

func NewServer(presenter ports.PresentationService, renderer ports.Renderer, config *entities.ServerConfig) (*Server, error)

NewServer creates a new HTTP server config must not be nil - use config.GetDefaultConfig().Server if needed Returns an error if config is nil

func NewServerWithLogging

func NewServerWithLogging(presenter ports.PresentationService, renderer ports.Renderer, config *entities.ServerConfig, loggingConfig *entities.LoggingConfig) (*Server, error)

NewServerWithLogging creates a new HTTP server with logging configuration Returns an error if config is nil

func (*Server) BroadcastFileChange

func (s *Server) BroadcastFileChange(filename string)

BroadcastFileChange sends a file change event to all connected clients

func (*Server) BroadcastReload

func (s *Server) BroadcastReload()

BroadcastReload sends a reload event to all connected clients

func (*Server) GetPresentation

func (s *Server) GetPresentation() *entities.Presentation

GetPresentation returns the current presentation

func (*Server) IsRunning

func (s *Server) IsRunning() bool

IsRunning returns whether the server is currently running

func (*Server) NotifyClients

func (s *Server) NotifyClients(event ports.UpdateEvent) error

NotifyClients sends an update event to all connected clients

func (*Server) SetExportService

func (s *Server) SetExportService(exportService ports.ExportService)

SetExportService sets the export service

func (*Server) SetLogger

func (s *Server) SetLogger(verbose bool)

SetLogger sets the HTTP logger with verbose configuration

func (*Server) SetOptimizationService

func (s *Server) SetOptimizationService(optimizationSvc *optimization.OptimizationService)

SetOptimizationService sets the optimization service

func (*Server) SetPresentation

func (s *Server) SetPresentation(p *entities.Presentation)

SetPresentation sets the current presentation

func (*Server) SetSyncService

func (s *Server) SetSyncService(syncService ports.PresentationSync)

SetSyncService sets the presentation sync service

func (*Server) Start

func (s *Server) Start(ctx context.Context, port int, host string) error

Start starts the HTTP server

func (*Server) Stop

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

Stop gracefully stops the HTTP server

type SlideResponse

type SlideResponse struct {
	Index int    `json:"index"`
	Title string `json:"title"`
	HTML  string `json:"html"`
	Notes string `json:"notes,omitempty"`
}

SlideResponse represents a single slide in the API response

type SlidesResponse

type SlidesResponse struct {
	Title  string          `json:"title"`
	Author string          `json:"author,omitempty"`
	Date   string          `json:"date,omitempty"`
	Theme  string          `json:"theme"`
	Slides []SlideResponse `json:"slides"`
}

SlidesResponse represents the slides API response

type WebSocketClient

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

WebSocketClient represents a WebSocket client connection

Jump to

Keyboard shortcuts

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