gzip

package
v0.0.0-...-d07672d Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConstDefaultCompression = uint8(6)
	ConstNoCompression      = uint8(gzip.NoCompression)
)
View Source
const TREEIFY_THRESHOLD = 1 << 8

Variables

This section is empty.

Functions

This section is empty.

Types

type Compress

type Compress struct {
	// contains filtered or unexported fields
}

func NewCompress

func NewCompress(compressConf *CompressConfig, featureOpts *FeatureOpts) *Compress

func (*Compress) CompressHandler

func (cs *Compress) CompressHandler() gin.HandlerFunc

CompressHandler 为压缩中间件,返回 gin.HandlerFunc 类型的函数处理路由请求

func (*Compress) Stop

func (cs *Compress) Stop()

type CompressConfig

type CompressConfig struct {
	Level              uint8    `json:"level,omitempty" yaml:"level,omitempty"`
	ExcludedPaths      []string `json:"excludedPaths,omitempty" yaml:"excludedPaths,omitempty"`
	ExcludedExtensions []string `json:"excludedExtensions,omitempty" yaml:"excludedExtensions,omitempty"`

	Logger *zap.SugaredLogger `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

func NewDefaultCompressConfig

func NewDefaultCompressConfig() *CompressConfig

func (*CompressConfig) InitializeMap

func (c *CompressConfig) InitializeMap()

type FeatureOpts

type FeatureOpts struct {
	EnableMetrics bool `json:"enableMetrics,omitempty" yaml:"enableMetrics,omitempty"` // 开启 metrics 记录
}

func NewDefaultFeatureOpts

func NewDefaultFeatureOpts() *FeatureOpts

type Writer

type Writer struct {
	gin.ResponseWriter
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(ginW gin.ResponseWriter, buff *bytes.Buffer, gzipW *gzip.Writer) *Writer

func (*Writer) Write

func (w *Writer) Write(b []byte) (int, error)

func (*Writer) WriteHeader

func (w *Writer) WriteHeader(code int)

Fix: https://github.com/mholt/caddy/issues/38

func (*Writer) WriteString

func (w *Writer) WriteString(s string) (int, error)

Jump to

Keyboard shortcuts

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