Documentation
¶
Overview ¶
Package web provides an embedded HTTP server for the initech web companion. It serves a single-page application from embedded static files and exposes a JSON API for pane information.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PaneInfo ¶
type PaneInfo struct {
Name string `json:"name"`
Host string `json:"host,omitempty"`
Activity string `json:"activity"`
Alive bool `json:"alive"`
Visible bool `json:"visible"`
}
PaneInfo describes a single managed pane. Mirrors tui.PaneInfo so the web package does not import tui directly.
type PaneLister ¶
PaneLister returns the current set of panes. The bool is false if the underlying system is shutting down and the data is unavailable.
type PaneSubscriber ¶
type PaneSubscriber interface {
// SubscribePane registers a subscriber for the named pane's PTY output.
// Returns a channel of byte slices and true if the pane exists, or
// nil and false if the pane is not found.
SubscribePane(paneName, subscriberID string) (chan []byte, bool)
// UnsubscribePane removes a subscriber. Safe to call if the pane or
// subscriber does not exist.
UnsubscribePane(paneName, subscriberID string)
}
PaneSubscriber provides fan-out subscription to a pane's PTY byte stream. The returned channel receives copies of all bytes read from the pane's PTY. Callers must call UnsubscribePane when done.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an HTTP server that serves the SPA and pane API.
func NewServer ¶
func NewServer(port int, lister PaneLister, subscriber PaneSubscriber, logger *slog.Logger) *Server
NewServer creates a Server bound to 127.0.0.1 on the given port. If port is 0, the OS assigns a free port. The subscriber parameter is optional; if nil, the /ws/pane/{name} endpoint returns 501.
func (*Server) Addr ¶
Addr returns the address the server is bound to. Only meaningful after Start has been called (and the listener is active).