compression

package module
v0.0.0-...-8280501 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: MIT Imports: 11 Imported by: 0

README

gin-compression

Compression middleware for gin-gonic

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gin

func Gin(configFns ...Configuration) gin.HandlerFunc

func Wrap

func Wrap(h http.Handler, configFns ...Configuration) http.Handler

Types

type BrotliCompressor

type BrotliCompressor struct {
	Options brotli.WriterOptions
}

func (*BrotliCompressor) Encoding

func (c *BrotliCompressor) Encoding() string

func (*BrotliCompressor) NewWriter

func (c *BrotliCompressor) NewWriter(w io.Writer) (io.WriteCloser, error)

func (*BrotliCompressor) Weight

func (c *BrotliCompressor) Weight() int

type Compressor

type Compressor interface {
	Encoding() string
	Weight() int
	NewWriter(w io.Writer) (io.WriteCloser, error)
}

type Compressors

type Compressors []Compressor

func (Compressors) Find

func (c Compressors) Find(encoding string) Compressor

func (Compressors) Len

func (c Compressors) Len() int

Len is the number of elements in the collection.

func (Compressors) Less

func (c Compressors) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (Compressors) Swap

func (c Compressors) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type Config

type Config struct {
	MinSize     int
	Compressors Compressors
	// contains filtered or unexported fields
}

type Configuration

type Configuration func(c *Config)

func WithBrotli

func WithBrotli(options brotli.WriterOptions) Configuration

func WithCompressor

func WithCompressor(compressor Compressor) Configuration

WithCompressor add custom compressor

func WithGzip

func WithGzip(level int) Configuration

func WithMinSize

func WithMinSize(minSize int) Configuration

func WithoutEncodings

func WithoutEncodings(encodings ...string) Configuration

WithoutEncodings remove already registered encodings

type GzipCompressor

type GzipCompressor struct {
	Level int
}

func (*GzipCompressor) Encoding

func (c *GzipCompressor) Encoding() string

func (*GzipCompressor) NewWriter

func (c *GzipCompressor) NewWriter(w io.Writer) (io.WriteCloser, error)

func (*GzipCompressor) Weight

func (c *GzipCompressor) Weight() int

Jump to

Keyboard shortcuts

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