Documentation
¶
Index ¶
- Constants
- func AcceptEncoding(c *elton.Context, encoding string) (bool, string)
- func New(config Config) elton.Handler
- func NewDefault() elton.Handler
- func NewWithDefaultCompressor(config Config) elton.Handler
- type BrCompressor
- type Compressor
- type Config
- type GzipCompressor
- type Lz4Compressor
- type S2Compressor
- type SnappyCompressor
- type ZstdCompressor
Constants ¶
View Source
const (
// BrEncoding br encoding
BrEncoding = "br"
)
View Source
const (
// GzipEncoding gzip encoding
GzipEncoding = "gzip"
)
View Source
const (
// Lz4Encoding lz4 encoding
Lz4Encoding = "lz4"
)
View Source
const (
// S2Encoding s2 encoding
S2Encoding = "s2"
)
View Source
const (
// SnappyEncoding snappy encoding
SnappyEncoding = "snz"
)
View Source
const (
// ZstdEncoding zstd encoding
ZstdEncoding = "zst"
)
Variables ¶
This section is empty.
Functions ¶
func AcceptEncoding ¶
AcceptEncoding check request accept encoding
func NewDefault ¶
NewDefault create a default compress middleware, support gzip
func NewWithDefaultCompressor ¶
NewWithDefaultCompressor create compress middleware with default compressor
Types ¶
type BrCompressor ¶
type BrCompressor struct{}
BrCompressor brotli compress
func (*BrCompressor) Accept ¶
func (b *BrCompressor) Accept(c *elton.Context) (acceptable bool, encoding string)
Accept check accept econding
type Compressor ¶
type Compressor interface { // Accept accept check function Accept(c *elton.Context) (acceptable bool, encoding string) // Compress compress function Compress([]byte, int) ([]byte, error) // Pipe pipe function Pipe(*elton.Context, int) error }
Compressor compressor interface
type Config ¶
type Config struct { // Levels compress levels, if not set the level for encoding, // it will use level config Levels map[string]int // Level compress level Level int // MinLength min compress length MinLength int // Checker check the data is compressable Checker *regexp.Regexp // Compressors compressor list Compressors []Compressor // Skipper skipper function Skipper elton.Skipper }
Config compress config
func (*Config) AddCompressor ¶ added in v0.1.1
func (conf *Config) AddCompressor(compressor Compressor)
AddCompressor add compressor
type GzipCompressor ¶
type GzipCompressor struct{}
GzipCompressor gzip compress
func (*GzipCompressor) Accept ¶
func (g *GzipCompressor) Accept(c *elton.Context) (acceptable bool, encoding string)
Accept accept gzip encoding
type Lz4Compressor ¶ added in v0.1.4
type Lz4Compressor struct{}
Lz4Compressor lz4 compress
func (*Lz4Compressor) Accept ¶ added in v0.1.4
func (*Lz4Compressor) Accept(c *elton.Context) (acceptable bool, encoding string)
Accept check accept encoding
type S2Compressor ¶ added in v0.1.4
type S2Compressor struct{}
S2Compressor s2 compressor
func (*S2Compressor) Accept ¶ added in v0.1.4
func (*S2Compressor) Accept(c *elton.Context) (acceptable bool, encoding string)
Accept check accept encoding
type SnappyCompressor ¶
type SnappyCompressor struct{}
SnappyCompressor snappy compress
func (*SnappyCompressor) Accept ¶
func (s *SnappyCompressor) Accept(c *elton.Context) (acceptable bool, encoding string)
Accept check accept encoding
type ZstdCompressor ¶ added in v0.1.4
type ZstdCompressor struct{}
ZstdCompressor zstd compress
func (*ZstdCompressor) Accept ¶ added in v0.1.4
func (*ZstdCompressor) Accept(c *elton.Context) (acceptable bool, encoding string)
Accept check accept encoding
Click to show internal directories.
Click to hide internal directories.