Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package gzip provides a simple middleware layer that performs gzip compression on the response.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
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 MIMEFilter ¶ added in v0.7.2
type MIMEFilter struct {
	// Types is the MIME types to accept.
	Types Set
}
    MIMEFilter is Filter for request content types.
func DefaultMIMEFilter ¶ added in v0.7.2
func DefaultMIMEFilter() MIMEFilter
DefaultMIMEFilter creates a MIMEFilter with default types.
func (MIMEFilter) ShouldCompress ¶ added in v0.7.2
func (m MIMEFilter) ShouldCompress(r *http.Request) bool
ShouldCompress checks if the content type of the request matches any of the registered ones. It returns true if found and false otherwise.
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.