assets

package
v0.0.0-...-4778944 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetEntry

type AssetEntry struct {
	LogicalPath string
	DiskPath    string // For disk-based (dev mode)
	// contains filtered or unexported fields
}

AssetEntry represents a single static asset that can be fingerprinted and served.

func (*AssetEntry) URL

func (e *AssetEntry) URL() string

URL returns the URL for the asset. In dev mode: returns plain path (no fingerprint) for live reload. In prod mode: returns fingerprinted path for cache busting.

type Assets

type Assets struct {
	// contains filtered or unexported fields
}

Assets manages fingerprinted static assets with build overlay support.

func LoadAssets

func LoadAssets(rootDir, mountPrefix string) (*Assets, error)

LoadAssets loads assets from filesystem (dev mode - live reload). Implements build overlay: checks build/ first, falls back to root.

func LoadAssetsFS

func LoadAssetsFS(fsys fs.FS, mountPrefix string) (*Assets, error)

LoadAssetsFS loads assets from embed.FS (prod mode - single binary). Implements build overlay: checks build/ first, falls back to root.

func (*Assets) Entries

func (a *Assets) Entries() map[string]*AssetEntry

Entries exposes the internal map for convenience.

func (*Assets) Entry

func (a *Assets) Entry(logical string) (*AssetEntry, error)

Entry retrieves the AssetEntry for the given logical path. In dev mode, returns an entry even for assets not registered at startup. Returns an error if Assets is nil, path is invalid, or asset not found (prod mode).

func (*Assets) MustEntry

func (a *Assets) MustEntry(logical string) *AssetEntry

MustEntry retrieves the AssetEntry for the given logical path. Panics if the asset is not found or path is invalid. Use this in templates where error handling is not practical.

func (*Assets) Register

func (a *Assets) Register(e *echo.Echo)

Register mounts a wildcard handler that serves all assets with fingerprint validation.

func (*Assets) URL

func (a *Assets) URL(logical string) string

URL returns the fingerprinted URL for a logical asset path. Returns empty string if asset not found or path is invalid.

Jump to

Keyboard shortcuts

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