Documentation
¶
Overview ¶
Package gzip provides a simple middleware layer that performs gzip compression on the response.
Index ¶
Constants ¶
const ExtWildCard = "*"
extWildCard is the wildcard for extensions.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExtFilter ¶ added in v0.7.2
type ExtFilter struct {
// Exts is the file name extensions to accept
Exts Set
}
ExtFilter is Filter for file name extensions.
func DefaultExtFilter ¶ added in v0.7.3
func DefaultExtFilter() ExtFilter
DefaultExtFilter creates an ExtFilter with default extensions.
type Filter ¶ added in v0.7.2
type Filter interface {
// ShouldCompress tells if gzip compression
// should be done on the request.
ShouldCompress(*http.Request) bool
}
Filter determines if a request should be gzipped.
type Gzip ¶
type Gzip struct {
Next middleware.Handler
Configs []Config
}
Gzip is a middleware type which gzips HTTP responses. It is imperative that any handler which writes to a gzipped response specifies the Content-Type, otherwise some clients will assume application/x-gzip and try to download a file.
type PathFilter ¶ added in v0.7.2
type PathFilter struct {
// IgnoredPaths is the paths to ignore
IgnoredPaths Set
}
PathFilter is Filter for request path.
func (PathFilter) ShouldCompress ¶ added in v0.7.2
func (p PathFilter) ShouldCompress(r *http.Request) bool
ShouldCompress checks if the request path matches any of the registered paths to ignore. It returns false if an ignored path is found and true otherwise.
type Set ¶ added in v0.7.2
type Set map[string]struct{}
Set stores distinct strings.
func (Set) ContainsFunc ¶ added in v0.7.2
ContainsFunc is similar to Contains. It iterates all the elements in the set and passes each to f. It returns true on the first call to f that returns true and false otherwise.