gzip

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 GinResponseWriter

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

GinResponseWriter is a wrapper response write using GZIP for Gin

func (*GinResponseWriter) Flush

func (g *GinResponseWriter) Flush()

func (*GinResponseWriter) Write

func (g *GinResponseWriter) Write(data []byte) (int, error)

func (*GinResponseWriter) WriteHeader

func (g *GinResponseWriter) WriteHeader(code int)

func (*GinResponseWriter) WriteString

func (g *GinResponseWriter) WriteString(s string) (int, error)

WriteString writes the string into the response body.

type Handler

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

Handler is a gzip handler

func Gzip

func Gzip() *Handler

Gzip returns a new gzip middleware.

func (*Handler) ApplyFunc

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

func (*Handler) Name

func (h *Handler) Name() string

Name returns the name of the middleware.

func (*Handler) Shutdown

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

Shutdown gzip noting to do here

type ResponseWriter

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

ResponseWriter is a wrapper for the http.ResponseWriter that compresses

func (*ResponseWriter) Close

func (r *ResponseWriter) Close() error

func (*ResponseWriter) Write

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

Jump to

Keyboard shortcuts

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