Compressible Content-Type / mime checking for Go.
import (
"github.com/teambition/compressible-go"
)
fmt.Println(compressible.Is("text/html"))
// -> true
fmt.Println(compressible.Is("image/png"))
// -> false
var wt compressible.WithTrashold = 1024
fmt.Println(wt.Compressible("text/html", 1023))
// -> false
Work with gear:
package main
import (
"github.com/teambition/compressible-go"
"github.com/teambition/gear"
"github.com/teambition/gear/middleware/static"
)
func main() {
app := gear.New()
app.Set(gear.SetCompress, compressible.WithThreshold(1024))
// Add a static middleware
app.Use(static.New(static.Options{
Root: "./",
Prefix: "/",
}))
app.Error(app.Listen(":3000")) // http://127.0.0.1:3000/
}
The docs can be found at godoc.org, as usual.
MIT