Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Compressible Content-Type / mime checking for Go.

License

Notifications You must be signed in to change notification settings

alibaba-archive/compressible-go

Repository files navigation

compressible-go

Build Status Coverage Status License GoDoc

Compressible Content-Type / mime checking for Go.

Demo

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/
}

Documentation

The docs can be found at godoc.org, as usual.

License

MIT

About

Compressible Content-Type / mime checking for Go.

Resources

License

Stars

Watchers

Forks

Packages

No packages published