Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPath ¶
GetPath returns the hashed, servable path for a logical asset name. Use this from templ templates: assets.GetPath(m, "scripts.js") -> "/assets/scripts.a1b2c3d4.js"
If the asset isn't found, it logs and returns the logical name unchanged so a missed rename fails loudly (404) rather than silently breaking the page.
func HandleAssets ¶
HandleAssets returns an http.Handler that serves assets at urlPrefix. Hashed paths (the normal case) get long-lived immutable caching. Unhashed/unknown paths fall through with no special caching, which lets you 404 cleanly or serve other static files from the same prefix if needed.
func New ¶
New walks fsys, computes a short content hash for every regular file, and returns a Manifest you can use to both build asset URLs and serve them.
root, if non-empty, is stripped as a prefix when building logical paths (useful if your embed.FS embeds "web/content" but you want asset paths like "scripts.js" rather than "web/content/scripts.js").