precompress

package
v1.40.1 Latest Latest
Warning

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

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

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 added in v1.34.0

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