Static asset pipeline: embed.FS + AssetVersion (bookshelf-qqz.8) #9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "bd-bookshelf-qqz.8"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
static/package with//go:embeddeclaration coveringcss/*.css,js/app.js,js/controllers/,js/vendor/,fonts/, andimg/Version(fs.FS) string: SHA-256 walk in sorted-path order, returns first 8 hex chars; deterministic and sensitive to any file changeHandler(embed.FS) http.Handler: strips/static/prefix, setsCache-Control: max-age=31536000, immutableon every response (including 404s) via acacheWriterwrapper that re-applies the header atWriteHeadertime (Go stdlibserveErrorintentionally clears caller-set headers on error paths)static/css/main.css: hand-written, ~110 lines,:rootCSS variables (--accent,--bg,--fg,--bg-card,--border,--radius, font stacks), base styles forbody/nav/main/links/headings/.cardstatic/js/app.js: placeholder comment; Stimulus bootstrap deferred to F-09static/fonts/.gitkeep,static/img/.gitkeep: track dirs before real assets landCoverage gate
scripts/check-coverage.shupdated to include./static/...in both-coverpkgand the test run so the 100% gate applies tostatic/too.Makefiletesttarget also updated.Test plan
make test— all 12 Static Suite specs pass, all other suites unchangedmake coverage— 100% on bothinternal/andstatic/Closes bead bookshelf-qqz.8 on merge.
Implements F-08 of the foundation epic: - static/static.go: //go:embed declaration covering css/*.css, js/app.js, js/controllers/, js/vendor/, fonts/, and img/ via all: prefix for dirs that only carry .gitkeep until F-09 lands. - static/version.go: Version(fs.FS) walks files in sorted-path order and returns the first 8 hex chars of SHA-256(path + content) per file. Deterministic; any change to path or bytes changes the hash. - static/handler.go: Handler(embed.FS) wraps http.FileServer with StripPrefix("/static/") and a cacheWriter that injects Cache-Control: max-age=31536000, immutable on every response, including 404s (Go stdlib serveError clears caller-set headers; the wrapper re-applies the header at WriteHeader time). - static/css/main.css: hand-written with :root CSS variables, minimal base styles for body/nav/main/links/headings/.card. ~110 lines. - static/js/app.js: placeholder comment; Stimulus bootstrap comes in F-09. - static/fonts/.gitkeep, static/img/.gitkeep: track dirs before real assets. - 100% test coverage on static/ package (ginkgo v2 + gomega). - scripts/check-coverage.sh: extended -coverpkg and test run to include ./static/... so the coverage gate enforces 100% on static/ too. - Makefile: test target now includes ./static/... alongside ./internal/... Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1b391e64e9toae77531fc4