ui

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package ui serves the embedded web UI bundle over HTTP with single-page application (SPA) routing semantics.

The compiled assets are embedded into the binary by package web; this package owns the request-handling policy on top of that fs.FS:

  • A request whose path maps to a real embedded file is served verbatim (e.g. GET /assets/app.js, GET /favicon.ico).
  • GET / serves the SPA shell (index.html).
  • A request for a path that has no embedded file and carries no file extension is treated as a client-side route (the front-end router is root-based: /jobs, /submit, /workers/{id}, …): the shell is returned so the router can resolve it on the client. The legacy /ui/* prefix is also honored. This is the SPA fallback.
  • A request whose path has a file extension but no embedded file (e.g. a stale /assets/old.js) returns 404, so missing assets are not masked by the shell.

The handler is mounted as the chi root catch-all (GET|HEAD /*) after every API and observability route, so it only ever sees paths those routes did not claim.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler serves the embedded web UI with SPA-fallback routing. Construct it with NewHandler and mount it as the root catch-all on the HTTP router.

func NewHandler

func NewHandler(logger *slog.Logger) (*Handler, error)

NewHandler builds a Handler backed by the embedded web/dist bundle. It returns an error only if the embedded asset tree cannot be opened, which indicates a build-time problem rather than a runtime condition.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler. See the package documentation for the routing policy it applies.

Jump to

Keyboard shortcuts

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