compress

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2023 License: MIT Imports: 9 Imported by: 0

README

http-compress

HTTP Compression middleware

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAllowedTypes = []*regexp.Regexp{
	regexp.MustCompile(`^text/`),
	regexp.MustCompile(`^application/json`),
	regexp.MustCompile(`^application/javascript`),
	regexp.MustCompile(`\+(xml|json)$`),
	regexp.MustCompile(`^image/svg`),
}

Functions

func DefaultErrorHandler added in v0.2.0

func DefaultErrorHandler(err error, _ *http.Request, w http.ResponseWriter)

func Handler

func Handler(h http.Handler, options ...Option) http.Handler

Types

type EncoderFactory

type EncoderFactory func(ctx context.Context, w io.Writer) (io.WriteCloser, error)

type ErrorHandler added in v0.2.0

type ErrorHandler func(error, *http.Request, http.ResponseWriter)

type Middleware added in v0.1.0

type Middleware func(http.Handler) http.Handler

func New added in v0.1.0

func New(options ...Option) Middleware

type Option

type Option func(*config)

func WihtoutEncoder

func WihtoutEncoder(encoding string) Option

func WithAllowedTypes

func WithAllowedTypes(list []*regexp.Regexp) Option

func WithEncoder

func WithEncoder(encoding string, priotity int, factory EncoderFactory) Option

func WithErrorHandler added in v0.2.0

func WithErrorHandler(handler ErrorHandler) Option

func WithGzip

func WithGzip(priority, level int) Option

func WithMinSize

func WithMinSize(minSize uint64) Option

Jump to

Keyboard shortcuts

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