gzip

package module
v0.0.0-...-6c03532 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2015 License: MIT Imports: 7 Imported by: 115 modules, 149 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

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

Documentation

Index

Constants

View Source
const (
	HeaderAcceptEncoding  = "Accept-Encoding"
	HeaderContentEncoding = "Content-Encoding"
	HeaderContentLength   = "Content-Length"
	HeaderContentType     = "Content-Type"
	HeaderVary            = "Vary"
	BestSpeed             = gzip.BestSpeed
	BestCompression       = gzip.BestCompression
	DefaultCompression    = gzip.DefaultCompression
)

Variables

This section is empty.

Functions

func All

func All(options ...Options) martini.Handler

All returns a Handler that adds gzip compression to all requests

Types

type Options

type Options struct {
	// Compression level. Can be DefaultCompression or any integer value between BestSpeed and BestCompression inclusive.
	CompressionLevel int
}

Options is a struct for specifying configuration options.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址