Skip to content
/ gzip Public
forked from martini-contrib/gzip

Martini handler for adding gzip compress to requests

License

Notifications You must be signed in to change notification settings

rex-ss/gzip

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gzip wercker status

Gzip middleware for Martini.

API Reference

Usage

import (
  "github.com/go-martini/martini"
  "github.com/martini-contrib/gzip"
)

func main() {
  m := martini.Classic()
  // gzip every request
  m.Use(gzip.All())
  m.Run()
}

Make sure to include the Gzip middleware above other middleware that alter the response body (like the render middleware).

Changing compression level

You can set compression level using gzip.Options:

import (
  "github.com/go-martini/martini"
  "github.com/martini-contrib/gzip"
)

func main() {
  m := martini.Classic()
  // gzip every request with maximum compression level
  m.Use(gzip.All(gzip.Options{
    CompressionLevel: gzip.BestCompression,
  }))
  m.Run()
}

The compression level can be DefaultCompression or any integer value between BestSpeed and BestCompression inclusive.

Authors

About

Martini handler for adding gzip compress to requests

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%