gzip

package
v0.0.0-...-28e2379 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2017 License: MIT, BSD-3-Clause Imports: 4 Imported by: 0

README

This code is from https://PuerkitoBio/ghost by Martin Angers. See LICENSE for licensing details.

The ghost library includes many dependencies that are not in use in this codebase (e.g. redis), so we copied the relevant code instead.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GZIPHandler

func GZIPHandler(h http.Handler, filterFn func(http.ResponseWriter, *http.Request) bool) http.HandlerFunc

Gzip compression HTTP handler. If the client supports it, it compresses the response written by the wrapped handler. The filter function is called when the response is about to be written to determine if compression should be applied. If this argument is nil, the default filter will GZIP only content types containing /json|text|javascript/.

func GZIPHandlerFunc

func GZIPHandlerFunc(h http.HandlerFunc, filterFn func(http.ResponseWriter, *http.Request) bool) http.HandlerFunc

GZIPHandlerFunc is the same as GZIPHandler, it is just a convenience signature that accepts a func(http.ResponseWriter, *http.Request) instead of a http.Handler interface. It saves the boilerplate http.HandlerFunc() cast.

func GetResponseWriter

func GetResponseWriter(w http.ResponseWriter,
	predicate func(http.ResponseWriter) bool) (http.ResponseWriter, bool)

Helper function to retrieve a specific ResponseWriter.

func HeaderMatch

func HeaderMatch(hdr http.Header, nm string, matchType HeaderMatchType, test string) bool

Check if the specified header matches the test string, applying the header match type specified.

Types

type HeaderMatchType

type HeaderMatchType int

Kind of match to apply to the header check.

const (
	HmEquals HeaderMatchType = iota
	HmStartsWith
	HmEndsWith
	HmContains
)

type WrapWriter

type WrapWriter interface {
	http.ResponseWriter
	WrappedWriter() http.ResponseWriter
}

This interface can be implemented by an augmented ResponseWriter, so that it doesn't hide other augmented writers in the chain.

Jump to

Keyboard shortcuts

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