gzip

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BestCompression    = gzip.BestCompression
	BestSpeed          = gzip.BestSpeed
	DefaultCompression = gzip.DefaultCompression
	NoCompression      = gzip.NoCompression
)

Variables

View Source
var (
	DefaultExcludedExtentions = NewExcludedExtensions([]string{
		".png", ".gif", ".jpeg", ".jpg",
	})
	DefaultOptions = &Options{
		ExcludedExtensions: DefaultExcludedExtentions,
	}
)

Functions

func Gzip

func Gzip(level int, options ...Option) http.HandlerFunc

func GzipBody

func GzipBody(r *http.Request) ([]byte, error)

Types

type ExcludedExtensions

type ExcludedExtensions map[string]bool

Using map for better lookup performance

func NewExcludedExtensions

func NewExcludedExtensions(extensions []string) ExcludedExtensions

func (ExcludedExtensions) Contains

func (e ExcludedExtensions) Contains(target string) bool

type ExcludedPaths

type ExcludedPaths []string

func NewExcludedPaths

func NewExcludedPaths(paths []string) ExcludedPaths

func (ExcludedPaths) Contains

func (e ExcludedPaths) Contains(requestURI string) bool

type ExcludedPathsRegex

type ExcludedPathsRegex []*regexp.Regexp

func NewExcludedPathsRegex

func NewExcludedPathsRegex(regexes []string) ExcludedPathsRegex

func (ExcludedPathsRegex) Contains

func (e ExcludedPathsRegex) Contains(requestURI string) bool

type Option

type Option func(*Options)

func WithExcludedExtensions

func WithExcludedExtensions(args []string) Option

func WithExcludedPaths

func WithExcludedPaths(args []string) Option

func WithExcludedPathsRegexes

func WithExcludedPathsRegexes(args []string) Option

func WithHandler

func WithHandler(decompressFn http.HandlerFunc) Option

type Options

type Options struct {
	ExcludedExtensions ExcludedExtensions
	ExcludedPaths      ExcludedPaths
	ExcludedPathsRegex ExcludedPathsRegex
	Handler            http.HandlerFunc
}

Jump to

Keyboard shortcuts

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