Documentation ¶
Overview ¶
Package compressible provides Compressible Content-Type / mime checking for Go.
Example ¶
fmt.Println(compressible.Is("text/html")) // -> true fmt.Println(compressible.Is("image/png")) // -> false var wt compressible.WithThreshold = 1024 fmt.Println(wt.Compressible("text/html", 1023)) // -> false
Output:
Index ¶
Examples ¶
Constants ¶
const Version = "1.0.1"
Version is Gear's version
Variables ¶
This section is empty.
Functions ¶
func Is ¶
Is checks the response Content-Type to determine whether to compress. Using mime database https://github.com/GitbookIO/mimedb to find which Content-Type is compressible. All types that not in mimedb but have the scheme of "text/*", "*/*+json", "*/*+text", "*/*+xml" are considered as compressible.
func Load ¶
func Load() error
Load loads all extensions and their content types of https://github.com/GitbookIO/mimedb to offical "mime" package. Recommond to apply this function in your main package's init function.
Types ¶
type WithThreshold ¶
type WithThreshold int
WithThreshold is an impelementation with transhold. The transhold defines the // minimun content length to enable compressible check.
func (WithThreshold) Compressible ¶
func (wt WithThreshold) Compressible(contentType string, contentLength int) bool
Compressible checks the response Content-Type to determine whether to compress. Using mime database https://github.com/GitbookIO/mimedb to find which Content-Type is compressible and WithThreshold as content length transhold All types that not in mimedb but have the scheme of "text/*", "*/*+json", "*/*+text", "*/*+xml" are considered as compressible.