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

Latest commit

 

History

History
59 lines (42 loc) · 1.51 KB

README.md

File metadata and controls

59 lines (42 loc) · 1.51 KB

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