static

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: LGPL-2.1 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SnapshotObj

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

SnapshotObj is an immutable metadata snapshot of the static tree. After New, fields are read-only, so concurrent serving needs no locks.

func New

func New(dir string, indexFile string, maxSize uint64, deny []string) (*SnapshotObj, error)

New builds an immutable metadata snapshot of dir.

Safety and bounds are fail-closed at startup, not during requests:

  • symlinks, devices, and sockets are skipped; only regular files are served;
  • deny rules apply to web paths by extension or prefix, case-insensitively;
  • per-file and total size are capped by maxSize; overflow is an error.

Map keys are cleaned absolute web paths, so "../" cannot escape the root and serving uses exact lookup only.

func (*SnapshotObj) Serve

func (obj *SnapshotObj) Serve(w http.ResponseWriter, r *http.Request)

Serve returns a file from the metadata snapshot; directories and "/" resolve to index_file. http.ServeContent handles Range, If-Range, status codes, and Last-Modified over the opened file. If-None-Match is handled by the ETag header, and files open only after snapshot lookup.

func (*SnapshotObj) SetCacheMaxAge

func (obj *SnapshotObj) SetCacheMaxAge(maxAge time.Duration)

SetCacheMaxAge sets Cache-Control max-age for served files. Negative values are ignored; call before serving because the snapshot is read-only afterwards.

Jump to

Keyboard shortcuts

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