Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Compressor ¶
type Compressor struct {
// contains filtered or unexported fields
}
Compressor represents a set of encoding configurations.
func NewCompressor ¶
func NewCompressor(types ...string) *Compressor
NewCompressor creates a new Compressor that will handle encoding responses.
The types are the content types that are allowed to be compressed.
func (*Compressor) Handler ¶
func (c *Compressor) Handler(next http.Handler) http.Handler
Handler returns a new middleware that will compress the response based on the current Compressor.
func (*Compressor) SetEncoder ¶
func (c *Compressor) SetEncoder(encoding string, fn EncoderFunc)
SetEncoder can be used to set the implementation of a compression algorithm.
The encoding should be a standardised identifier. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding
type EncoderFunc ¶
An EncoderFunc is a function that wraps the provided io.Writer with a streaming compression algorithm and returns it.
In case of failure, the function should return nil.