gzip

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gzip

func Gzip() handler.Middleware

Types

type Config

type Config struct {
	// MinSize is the minimum size to trigger compression. Default is 1024 bytes(1KB).
	MinSize int `json:"minSize" yaml:"minSize"`
	// gzip.DefaultCompression is used if Level is not set.
	// 0 : gzip.NoCompression; 1 - 9 : gzip.BestSpeed - gzip.BestCompression; -1 : gzip.DefaultCompression; -2 : gzip.HuffmanOnly
	Level int `json:"level" yaml:"level"`
	// ExcludedExtensions is a list of file extensions to skip compressing.
	ExcludedExtensions []string `json:"excludedExtensions" yaml:"excludedExtensions"`
	// contains filtered or unexported fields
}

Config is the configuration for the gzip middleware. Support min size and level setting

type Middleware added in v0.4.0

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

Middleware is a gzip handler

func NewGzip added in v0.4.0

func NewGzip() *Middleware

NewGzip returns a new gzip middleware.

func (*Middleware) ApplyFunc added in v0.4.0

func (h *Middleware) ApplyFunc(cfg *conf.Configuration) gin.HandlerFunc

func (*Middleware) Name added in v0.4.0

func (h *Middleware) Name() string

Name returns the name of the middleware.

func (*Middleware) Shutdown added in v0.4.0

func (h *Middleware) Shutdown(_ context.Context) error

Shutdown gzip noting to do here

type ResponseWriter

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

ResponseWriter is a wrapper for the http.ResponseWriter that compresses

func (*ResponseWriter) Close

func (r *ResponseWriter) Close() (err error)

func (*ResponseWriter) Write

func (r *ResponseWriter) Write(data []byte) (int, error)

func (*ResponseWriter) WriteHeader added in v0.3.0

func (r *ResponseWriter) WriteHeader(code int)

func (*ResponseWriter) WriteString added in v0.3.0

func (r *ResponseWriter) WriteString(s string) (int, error)

Jump to

Keyboard shortcuts

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