gzip

package
v1.12.4 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: Apache-2.0 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 (
	DefaultExcludedExtensions = NewExcludedExtensions([]string{
		".png", ".gif", ".jpeg", ".jpg",
	})
	DefaultOptions = &Options{
		ExcludedExtensions: DefaultExcludedExtensions,
	}
)

Functions

func DefaultDecompressHandle

func DefaultDecompressHandle(c *gin.Context)

func Gzip

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

Types

type ExcludedExtensions

type ExcludedExtensions map[string]bool

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 ExcludedPathsRegexes

type ExcludedPathsRegexes []*regexp.Regexp

func NewExcludedPathsRegexes

func NewExcludedPathsRegexes(regexs []string) ExcludedPathsRegexes

func (ExcludedPathsRegexes) Contains

func (e ExcludedPathsRegexes) Contains(requestURI string) bool

type Option

type Option func(*Options)

func WithDecompressFn

func WithDecompressFn(decompressFn func(c *gin.Context)) Option

func WithExcludedExtensions

func WithExcludedExtensions(args []string) Option

func WithExcludedPaths

func WithExcludedPaths(args []string) Option

func WithExcludedPathsRegexes

func WithExcludedPathsRegexes(args []string) Option

type Options

type Options struct {
	ExcludedExtensions   ExcludedExtensions
	ExcludedPaths        ExcludedPaths
	ExcludedPathsRegexes ExcludedPathsRegexes
	DecompressFn         func(c *gin.Context)
}

Jump to

Keyboard shortcuts

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