Documentation
¶
Overview ¶
Package server provides the HTTP preview server for mdp.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
File string
Port int
OpenBrowser bool
Theme string // built-in theme name, file path, or "auto".
HljsTheme string // vendored hljs sheet for custom theme files (github, github-dark).
ScrollSync bool // Enable scroll sync via /cursor endpoint.
CustomCSS string // Path to custom CSS file to inject after default styles.
OpenToNetwork bool // Listen on 0.0.0.0 instead of localhost.
IdleTimeout time.Duration // Shut down when no clients connected for this long (0 = disabled).
}
Config holds the server configuration.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the HTTP preview server.
func New ¶
New creates a new Server from the given config. The listen address is resolved eagerly so callers can read it via Addr() before calling ListenAndServe.
func (*Server) Broadcast ¶
Broadcast parses the given markdown and sends the rendered HTML to all connected WebSocket and SSE clients.
func (*Server) BroadcastFile ¶
BroadcastFile reads the configured file and broadcasts its rendered content.
func (*Server) Close ¶
func (s *Server) Close()
Close shuts down the server, closing all WebSocket and SSE connections.
func (*Server) ListenAndServe ¶
ListenAndServe starts the HTTP server and blocks until it exits. Returns nil on clean shutdown (e.g. idle timeout or Close()).
func (*Server) ReadStdin ¶
ReadStdin reads newline-delimited JSON messages from r and dispatches them. It blocks until r is closed or an unrecoverable error occurs.
func (*Server) SendCursor ¶
SendCursor broadcasts a cursor position update to all connected clients.