Functions
func GenerateStatic(outputDir string, options Options) error
GenerateStatic writes a read-only static export of the Web UI to outputDir,
replacing what is there.
func Handler(options Options) http.Handler
Handler serves the Web UI and its JSON API.
func IsLoopbackHost(host string) bool
IsLoopbackHost reports whether host only accepts local connections.
func LaunchProxyPath(id string) string
LaunchProxyPath is the URL path a service launch is served under; the
service receives it as ROTARI_LAUNCHER_BASE_PATH.
func Listen(host string, port int, fallback bool) (net.Listener, error)
Listen listens on host and port. With fallback, a busy port is followed by
the next free one.
func TableViewHandler(path string) (http.Handler, error)
TableViewHandler serves the Table viewer for one table, document,
or directory named on the command line (rotari tableview), with the fonts
and design tokens its page links. It reads only under that directory,
or the file's: the only root, and the only base media paths resolve from.
For a directory, the query's child names a file or directory inside it to
show instead, as for an artifact.
func WithAuthToken(next http.Handler, token string, options AuthOptions) http.Handler
WithAuthToken protects the Web UI with an interactive login session and
accepts bearer or X-Rotari-Token credentials for API clients.
func WithExecGuard(next http.Handler, allowedHosts []string) http.Handler
WithExecGuard protects a server that can launch commands from requests a
browser makes on behalf of another site:
- Host must be a loopback name or one of allowedHosts (DNS rebinding).
- A request that is not GET or HEAD, and a WebSocket handshake, must
carry an Origin equal to its own scheme and Host, or, without Origin,
an X-Rotari-Token or bearer Authorization header, which a browser
never adds by itself. A missing Origin is never taken as proof that the
request is same-origin.
Authentication itself is WithAuthToken's job.
Types
type About struct {
Version string
Executable string
ExecutableError string
}
site serves one Options. About is which rotari serves the pages:
its version, as rotari version prints it, and the path of its binary,
or why that is not known.
type AuthEvent struct {
Event string
Outcome string
Transport string
Cookie string
CookieSecure *bool
UserAgent string
}
AuthEvent is one allow-listed authentication decision. It intentionally has
no URL, credential, cookie value, headers, or client address fields.
type AuthOptions struct {
Recorder AuthRecorder
OnSignOut []func()
}
AuthOptions supplies optional authentication hooks.
type AuthRecorder interface {
RecordAuthEvent(AuthEvent)
}
AuthRecorder receives authentication decisions without learning any
credential or request details beyond the bounded user agent.
type LaunchOptions struct {
Manager *launcher.Manager
Registry launcher.Registry
// Has unexported fields.
}
LaunchOptions enables launching registered commands from artifacts (rotari
web --allow-exec).
type Options struct {
BaseDir string
// WorkspaceDir is captured at server startup, never a viewed job's cwd.
WorkspaceDir string
// RootBaseDir is the Web process's original state directory and anchors
// the unprefixed routes while the browser switches to other basedirs.
RootBaseDir string
// BaseDirs are previously registered state directories available to switch
// to from the sidebar. BaseDir is always included.
BaseDirs []string
// ReloadBaseDirs, when set, rereads BaseDirs on each page load and on
// /api/basedirs (the Refresh button); other requests reuse the last list.
ReloadBaseDirs func() ([]string, error)
// AllowControl enables the endpoints that edit queues, configs, and runs.
AllowControl bool
// AuthEnabled adds the sign-out control to the main Web page.
AuthEnabled bool
// Notifications is the default of the desktop notification toggle.
Notifications bool
// ArtifactRoots are directories, besides each job's working directory,
// whose recorded artifact candidates the live server may serve.
ArtifactRoots []string
// StaticArtifactContents makes a static export copy the contents of
// previewable artifact candidates, so previews work without a server.
StaticArtifactContents bool
// StaticArtifactsCopied, when set, is told how many files and bytes a
// static export copied for StaticArtifactContents.
StaticArtifactsCopied func(files int, bytes int64)
// NotificationLog holds the notifications runs recorded, which the live
// inbox shows; nil for a static export.
NotificationLog *notificationlog.Log
// Launches is set when rotari web runs with --allow-exec.
Launches *LaunchOptions
// Terminal is set when rotari web runs with --allow-terminal.
Terminal *terminal.Keeper
// Shutdown stops the live server as SIGTERM does; POST /_server/shutdown and the
// Settings menu's Stop server call it when job control is on. Nil for a static
// export, which has neither.
Shutdown func()
// About says which rotari serves the pages, in their Settings menu; empty for a
// static export and when nothing says.
About About
// LauncherFile is where launchers.toml is read from. Explanations of why
// launching is unavailable name it even when Launches is nil.
LauncherFile string
Store state.Store
Editor queueops.Editor
Controller jobcontrol.Controller
// Executors lists the executor names the UI offers.
Executors []string
// Environments are included in the Web state projection.
Environments []web.EnvironmentDefinition
// ConfigTemplate returns the TOML config template that "generate config"
// writes.
ConfigTemplate func() ([]byte, error)
ConfigTemplateForScope func(string) ([]byte, error)
}
Options configures the Web UI for one base directory.
type StaticTableViewCopy struct {
Rows, MediaFiles int
MediaBytes int64
}
StaticTableViewCopy is what a static snapshot holds: the rows, and the media
files copied with their total size.
func GenerateStaticTableView(path, outputDir string) (StaticTableViewCopy, error)
GenerateStaticTableView writes a static snapshot of the Table viewer for one
delimited or JSON Lines file to outputDir (rotari tableview --static-dir).
A delimited file uses the separator its extension suggests and a header row;
JSON Lines records keep their object keys as columns. The snapshot contains
every row with its order under each sort and its Describe, and the media
files its cells name, copied beside the page. The page is titled with the
file's name alone. It reads only under the file's directory, as rotari
tableview does.