gzip

package module
v0.0.0-...-e9a92fd Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2015 License: MIT Imports: 5 Imported by: 0

README

go-gzip-middleware

Gzip Middleware for use with https://github.com/julienschmidt/httprouter

Build Status Coverage GoDoc

Documentation

Overview

GZip Middleware for the excellent HTTPRouter from @julienschmidt http://godoc.org/github.com/julienschmidt/httprouter

Example usage:

 	import (
		"github.com/socialradar/go-gzip-middleware"
	)

	// ...

	router := httprouter.New()
	router.Get("/path", gzip.Middleware(HandlePath, false))

This middleware will gzip any requests with the `Accept-Encoding=gzip` header.

It also includes a bool option to force gzip all requests, regardless of whether or not that gzip header is present on the request. For example:

router.Get("/path", gzip.Middleware(HandlePath, true))

Supplying `true` as the second argument will force Gzip every response regardless of the client `Accept-Encoding` header.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(fn httprouter.Handle, force bool) httprouter.Handle

fn - The httprouter handler function force - bool, whether or not to force Gzip regardless of the sent headers.

Types

type GzipResponseWriter

type GzipResponseWriter struct {
	io.Writer
	http.ResponseWriter
}

func (GzipResponseWriter) Write

func (w GzipResponseWriter) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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