web

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package web serves the single-page UI the controller binary was built with.

It is a root package rather than part of api for two reasons: api stays data-only, so nothing importing it links an embedded asset tree, and the private companion imports api's neighbours freely. api never imports this package — the wiring lives where all wiring lives, in controller.serve, which builds a Handler and passes it in as api.Options.UI.

A binary built without running Vite embeds nothing, and every UI route then answers a plain-text page saying so. That is what keeps `go build ./...`, `go test ./...` and `go install …@latest` working with no Node installed, which is what the getting-started guide promises today.

Index

Constants

This section is empty.

Variables

View Source
var Assets = sub(bundle, "dist")

Assets is the built UI, rooted at the bundle itself: index.html and assets/ are at its top level, not under dist/.

Rooted here rather than in Handler so that the fs.FS Handler takes is the thing it documents — a caller handing it a test filesystem writes the paths a browser asks for, and no caller has to know where the embed happened to put them.

Functions

func Handler

func Handler(assets fs.FS, o Options) http.Handler

Handler serves the UI out of assets: index.html and assets/ at its top level.

Whether a UI was built at all is decided once, here, by reading the index rather than by asking whether the filesystem is empty. A bundle carrying assets and no index is exactly as unserveable as an empty one, and would otherwise answer every route with a blank 200 instead of saying what is wrong.

Types

type Options

type Options struct {
	// Log reports an assets filesystem that could not be read at all — which is
	// not the same thing as a build with no UI, and is otherwise a page an
	// operator cannot explain with nothing anywhere saying why.
	Log *slog.Logger
}

Options tune a Handler. Every field has a working default.

Jump to

Keyboard shortcuts

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