Documentation
¶
Index ¶
Constants ¶
View Source
const ( EncodingGzip = "gzip" EncodingDeflate = "deflate" )
Variables ¶
Functions ¶
func New ¶
func New(config ...Config) fh.HandlerFunc
Types ¶
type Config ¶
type Config struct {
Level int
MinSize int
// CompressibleTypes uses prefix matching.
CompressibleTypes []string
Encoder Encoder
Next func(ctx fh.Ctx) bool
// BreachProtection skips compression when the response carries
// security-sensitive headers (Set-Cookie, Content-Security-Policy,
// Authorization) to mitigate BREACH-style side-channel attacks.
BreachProtection bool
}
type DeflateEncoder ¶
type DeflateEncoder struct {
// contains filtered or unexported fields
}
DeflateEncoder compresses responses using the DEFLATE algorithm (compress/flate). Deflate is universally supported by browsers and requires no external dependencies.
func NewDeflateEncoder ¶
func NewDeflateEncoder(level int) *DeflateEncoder
NewDeflateEncoder creates a new deflate encoder at the given compression level.
func (*DeflateEncoder) Encode ¶
func (d *DeflateEncoder) Encode(dst *bytes.Buffer, src []byte) error
func (*DeflateEncoder) Encoding ¶
func (d *DeflateEncoder) Encoding() string
type GzipEncoder ¶
type GzipEncoder struct {
// contains filtered or unexported fields
}
func NewGzipEncoder ¶
func NewGzipEncoder(level int) *GzipEncoder
func (*GzipEncoder) Encoding ¶
func (e *GzipEncoder) Encoding() string
Click to show internal directories.
Click to hide internal directories.