runtimeassets

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 7 Imported by: 0

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 five runtime assets served here:

gothic-core.js       the shared idempotent client runtime (pkg/helpers/gothiccore)
gothic-core.wasm     the prebuilt full-Go static core module (pkg/helpers/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 (pkg/data/wasm_exec)

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 three 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

View Source
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

func Handler() http.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), and writes the bytes. Unknown names 404. Only GET/HEAD are meaningful; other methods 405.

func Path

func Path(name, version string) string

Path returns the referencing URL for an asset name: Prefix+name+"?v="+version.

Types

type Asset

type Asset struct {
	Name        string
	Bytes       []byte
	ContentType string
	Version     string
}

Asset is one served runtime file: its basename (the path segment after the prefix), the bytes to write, its Content-Type, and the content-hash used as the ?v= cache-buster in the URL that references it.

func All

func All() []Asset

All returns every registered asset (unordered).

func Get

func Get(name string) (Asset, bool)

Get returns the asset registered under name (the path segment after Prefix), and whether it exists.

Jump to

Keyboard shortcuts

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