Documentation
¶
Overview ¶
Package runtimeassets is the single registry + HTTP handler for the Gothic framework's WASM-runtime assets that used to be COPIED into every project's public/ folder at `gothic init` / build time. Instead of shipping bytes into the user's tree, the framework now serves them straight from its own embed under a dedicated route prefix (/_gothic/), so a framework upgrade updates the runtime for every project with no file churn and no stale copies.
The runtime assets served here:
gothic-core.js the shared idempotent client runtime (gothiccore, minified) gothic-core.wasm the prebuilt full-Go static core module (corewasm) gothic-core-exec.js the standard-Go wasm_exec shim matched to the core (corewasm) gothic-core-boot.js the generated core boot loader (corewasm) wasm_exec.js the TinyGo wasm_exec shim (wasmexec)
Every asset is content-negotiated: each one's brotli and gzip variants are precomputed at BUILD TIME (by `go generate`, see gen.go) and embedded, and the handler serves the smallest form the client accepts (Content-Encoding: br|gzip), falling back to the raw bytes. Compressing at build time (not at startup) is what keeps the server's cold start fast — brotli q11 on the ~1.9 MB gothic-core.wasm takes seconds of CPU, so doing it once at release time instead of on every process start is the difference between an instant boot and a slow one. (A CDN in front is free to keep doing its own compression too.)
NOTE the user's own GOROOT-matched wasm_exec_go.js stays in public/ (it is version-tied to the user's Go toolchain, copied at build time — not a framework artifact) and the per-page user WASM binaries stay under /public/wasm/.
This is a LEAF package over the asset-owning leaf packages (gothiccore, corewasm, wasmexec). Those packages must NOT import runtimeassets or a cycle forms — runtimeassets sits one level above them.
Index ¶
Constants ¶
const Prefix = "/_gothic/"
Prefix is the route namespace the framework serves its runtime assets under. It is deliberately distinct from /public/ so it never collides with a user's static files and can carry its own edge-cache behavior at the CDN.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
Handler serves the runtime assets under Prefix. It strips the prefix, looks the file up in the registry, sets the right Content-Type, marks it immutable when a ?v= cache-buster is present (mirroring immutableCacheMiddleware), negotiates a compressed encoding from Accept-Encoding, and writes the bytes. Unknown names 404. Only GET/HEAD are meaningful; other methods 405.
Types ¶
type Asset ¶
type Asset struct {
Name string
Bytes []byte // identity (uncompressed)
Brotli []byte // brotli-compressed, or nil if not smaller than Bytes
Gzip []byte // gzip-compressed, or nil if not smaller than Bytes
ContentType string
Version string
}
Asset is one served runtime file: its basename (the path segment after the prefix), the raw bytes, precompressed brotli/gzip variants (nil when a variant is not smaller than the raw bytes), its Content-Type, and the content-hash used as the ?v= cache-buster in the URL that references it.