compress

package module
v0.0.0-...-481bb1a Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2016 License: MIT Imports: 9 Imported by: 1

README

compress

GoDoc

Middleware to compress http responses with gzip or deflate

Documentation

Overview

Package compress provides a middleware for compression via gzip and deflate.

Index

Constants

This section is empty.

Variables

View Source
var (
	// CompressMinLength is the lower bound for compression. Smaller files
	// won't be compressed.
	CompressMinLength = 256
	// CompressMaxBuf is the upper bound for buffered compression. Larger files
	// will be compressed on-the-fly.
	CompressMaxBuf = 16 * 1024
)

Functions

func New

func New(h http.Handler) http.Handler

New wraps a http.Handler and adds compression via gzip or deflate to the response. The Middleware takes care to not compress twice and will only compress known mimetypes. Small responses will be buffered completely and the Content-Length header will be set accordingly. Large responses as well as responses with unknown length will be compressed on the fly.

...
log.Fatal(http.ListenAndServe(":8080", compress.New(http.DefaultServeMux))
...

func NewLevel

func NewLevel(h http.Handler, level int) http.Handler

NewLevel allows to set the compression level. See compress/flate.

Types

This section is empty.

Jump to

Keyboard shortcuts

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