Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
Handler returns an http.Handler that serves static files from dir.
When spa is true, requests for paths that don't match an existing file are served with dir/index.html (SPA client-side routing fallback).
Cache headers use CacheOpts (defaults when empty): hashed bundle prefixes get a long immutable cache; .html and "/" get no-cache; SPA fallback uses the HTML policy.
Precompressed assets: for request path P, if P.br or P.gz exists on disk and the client sends a matching Accept-Encoding token, that file is served with Content-Encoding set (prefer brotli over gzip when both are acceptable). If both uncompressed P and P.br exist, the precompressed file is preferred when the client accepts that encoding. When no precompressed sidecar exists, compressible text types may be gzip-compressed on the fly (small files only; Range requests skip on-the-fly gzip and use plain ServeContent).