Documentation
¶
Overview ¶
Package web holds the files muster serves under /static/, plus the two root-scoped PWA documents (/sw.js and /manifest.webmanifest).
🔴 EVERY FILE IN static/ IS A BUILD INPUT, NOT AN ARTIFACT, AND THAT IS WHY app.css IS COMMITTED HERE AND IGNORED UPSTREAM. The `//go:embed` below makes `go build ./...` fail on a fresh clone if any of these files is absent — so a stylesheet that only exists after `npm run build:css` would mean the project does not build until a contributor discovers a step nothing told them about. The repository's .gitignore says the same thing in its first line: nothing `go build` needs may be ignored. `make css-check` is what keeps the committed copy from going stale.
⚠ NO `all:` PREFIX, DELIBERATELY. `//go:embed static` skips entries whose names begin with `.` or `_`. There are none, and adding one would be a silent omission — a vendored asset that stops being served with no build error. If a dotfile ever has to ship, change the directive AND add it to the derived asset test in internal/api, which is what would otherwise not notice.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Files fs.FS = overlay{}
Files is what /static/ serves: the embedded tree (Static) with the generated files laid over it. Its root holds the static/ directory, as Static's does.
var Static embed.FS
Static holds everything served under /static/ (app.css, vendor/*.js, icons/*.png) as well as sw.js and manifest.webmanifest, which are served from the root so the service worker's scope is "/".
Functions ¶
func Asset ¶
Asset is the URL a page links a /static/ file at: the path with ?v=<content hash> appended, e.g. "/static/app.css?v=3f9c1a0b2d4e".
🔴 A CONTENT HASH, NOT THE BUILD VERSION. muster 0.43.0 shipped a stylesheet change (the "N new" pill's .top-20) behind an unversioned /static/app.css, and Cloudflare and browsers kept serving the old copy (the edge answered max-age=14400 with a cf HIT): the pill drew at the bottom of the page. The hash changes exactly when the file's bytes do, so a release that leaves a file alone leaves every cache of it warm, and one that changes it is a new URL no cache has seen. The server marks a URL carrying the CURRENT hash immutable (see internal/api staticHandler).
A path that is not in the embedded tree is returned unchanged — the static-assets test in internal/api fails on it first.
func Register ¶
Register adds a generated file at urlPath ("/static/js/<name>.js") and returns urlPath, so a package-level var can both register and name it.
It panics — at init, so a build that does it never starts — on a path outside /static/js/, on a path registered twice, and on a path the embed already carries: each would serve one of two different files under one URL.
Types ¶
This section is empty.