precompress

package
v0.0.0-...-9d29f1b Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package precompress provides build- and serving-time support for precompressed static resources, to avoid the cost of repeatedly compressing unchanging resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenPrecompressedFile

func OpenPrecompressedFile(w http.ResponseWriter, r *http.Request, path string, fs fs.FS) (fs.File, error)

OpenPrecompressedFile opens a file from fs, preferring compressed versions generated by PrecompressDir if possible.

func Precompress

func Precompress(path string, options Options) error

func PrecompressDir

func PrecompressDir(dirPath string, options Options) error

PrecompressDir compresses static assets in dirPath using Gzip and Brotli, so that they can be later served with OpenPrecompressedFile.

Types

type Options

type Options struct {
	// FastCompression controls whether compression should be optimized for
	// speed rather than size.
	FastCompression bool
	// ProgressFn, if non-nil, is invoked when a file in the directory is about
	// to be compressed.
	ProgressFn func(path string)
}

Jump to

Keyboard shortcuts

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