Documentation
¶
Overview ¶
Package api serves Stormlight's domain over HTTP and WebSockets: a second head on the same internal/app.Service the dashboard drives, so a browser client and the TUI are peers over one set of rules rather than two implementations of them.
Two planes share the listener and never mix. The control plane is JSON over HTTP — roster, workspaces, dispatch, history — where a millisecond costs nothing. The data plane is one WebSocket per attached terminal, carrying raw bytes in both directions: keystrokes are never wrapped in JSON and never queued behind a request. That split is what keeps typing in a browser terminal feel like typing in a terminal.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Assets ¶ added in v0.12.0
Assets is the built frontend, handed in by the command that has it embedded. Nil serves nothing: the API is complete without a page, and a build that skipped the frontend should say so honestly rather than serve a blank one.
type Option ¶ added in v0.15.0
type Option func(*Server)
Option adjusts how the server runs.
func WithActions ¶ added in v0.15.0
func WithActions(dispatcher *action.Dispatcher) Option
WithActions makes this server a dashboard that runs agents' action requests: the roster poll that feeds the event stream also feeds the dispatcher, and it polls whether or not a browser is connected, because the actions run here regardless of who is watching.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the HTTP surface. It owns no state the dashboard does not already own — every route is a decode, one Service call, and an encode.
func New ¶
New builds the server. The token is required, not optional: these routes dispatch agents and stream terminals in every workspace the catalog knows, which is shell access to all of them. There is deliberately no unauthenticated mode to ship by accident. assets is the built web client, or nil to serve the API alone.