Documentation ¶
Index ¶
Constants ¶
const ManifestFilename string = "staticfiles.json"
const ManifestVersion int = 1
Variables ¶
var ErrManifestVersionMismatch = errors.New("manifest version mismatch")
Functions ¶
func FileSystem ¶
func FileSystem(path string, disableDirList bool) http.FileSystem
Returns http.FileSystem implementation to be used in http.FileServer to serve static files. disableDirList param allows to disable directories listing (in opposite to as it goes by default with http.Dir).
func PostProcessCSS ¶
func PostProcessCSS(storage *Storage, file *StaticFile) error
Post-process CSS files to fix references to the static files in the following cases: - url("../path/file.ext") - @import "path/file.ext" - sourceMappingURL=style.css.map
Types ¶
type ManifestScheme ¶
type PostProcessRule ¶
type PostProcessRule func(*Storage, *StaticFile) error
type StaticFile ¶
type Storage ¶
type Storage struct { Root string FilesMap map[string]*StaticFile // contains filtered or unexported fields }
func NewStorage ¶
func (*Storage) AddInputDir ¶
func (*Storage) CollectStatic ¶
Collects files from Storage.inputDir (including subdirectories), compute hash of each file, append hash sum to the filenames, apply post-process rules, copy files to the Storage.Root directory along with the manifest file, containing map original paths to the storage paths.
func (*Storage) LoadManifest ¶
Loads data from ManifestFilename, stored in the Storage.Root directory, to the Storage.FilesMap. Manifest contains files mapping from the original relative paths to the storage relative paths.
func (*Storage) RegisterRule ¶
func (s *Storage) RegisterRule(rule PostProcessRule)
func (*Storage) Resolve ¶
Resolve file path relative to the one of the Storage.inputDirs to the storage path relative to the Storage.Root.