static

package
v0.5.18 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package static contains static assets and code relating to serving of static assets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHandler

func AddHandler(logger logr.Logger, r *mux.Router) error

AddHandler adds a handler to router serving static assets (JS, CSS, etc) from within go binary. Enabling developer mode sources files from local disk instead and starts a live reload server, which reloads the browser whenever static files change.

Types

type CacheBuster

type CacheBuster struct {
	fs.FS
}

CacheBuster provides a cache-busting filesystem wrapper, mapping paths with a specific format containing a sha256 hash to paths without the hash in the wrapped filesystem. i.e. mapping

/css/main.1fc822f99a2cfb6b5f316f00107a7d2770d547b64f3e0ea69baec12001a95f9f.css -> /css/main.css

var (
	AssetsFS *CacheBuster
)

func (*CacheBuster) Open

func (cb *CacheBuster) Open(fname string) (http.File, error)

Open strips the hash from the name before opening it in the wrapped filesystem.

func (*CacheBuster) Path

func (cb *CacheBuster) Path(fname string) (string, error)

Path inserts a hash of the named file into its filename, before the filename extension: <path>.<ext> -> <path>.<hash>.<ext>, where <hash> is the hex format of the SHA256 hash of the contents of the file.

Jump to

Keyboard shortcuts

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