gzip

package
v16.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 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 DefaultConfig = Config{
	Skipper:   middleware.DefaultSkipper,
	Level:     DefaultCompression,
	MinLength: 0,
}

DefaultConfig is the default Gzip middleware config.

Functions

func ContentTypeSkipper added in v16.10.0

func ContentTypeSkipper(contentTypes []string) middleware.Skipper

ContentTypesSkipper returns a Skipper based on the list of content types that should be compressed. If the list is empty, all responses will be compressed.

func New

func New() echo.MiddlewareFunc

New returns a middleware which compresses HTTP response using gzip compression scheme.

func NewWithConfig

func NewWithConfig(config Config) echo.MiddlewareFunc

NewWithConfig return Gzip middleware with config. See: `New()`.

Types

type Config

type Config struct {
	// Skipper defines a function to skip middleware.
	Skipper middleware.Skipper

	// Gzip compression level.
	// Optional. Default value -1.
	Level int

	// Length threshold before gzip compression
	// is used. Optional. Default value 0
	MinLength int
}

Config defines the config for Gzip middleware.

Jump to

Keyboard shortcuts

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