encoding - ActiveState ActiveGo 1.8
...

Package encoding

import "github.com/streadway/handy/encoding"
Overview
Index

Overview ▾

Package encoding contains Content-Encoding related filters.

func Gzip

func Gzip(next http.Handler) http.Handler

Gzip calls the next handler with a response writer that will compress the outbound writes with the default compression level. This filter assumes a chunked transfer encoding, so do not add a Content-Length header in the terminal handler.

If the request does not accept a gzip encoding, this filter has no effect.

func GzipTypes

func GzipTypes(mediaTypes []string, next http.Handler) http.Handler

GzipTypes sets the gzips the response if the the request Accept-Encoding contains 'gzip' and the response 'Content-Type' contains one of the mediaTypes. When no or nil mediaTypes are provided, all content types will be gzip encoded.

func Gzipper

func Gzipper(level int, mediaTypes ...string) func(http.Handler) http.Handler

Gzipper returns a composable middleware function that wraps a given http.Handler with outbound Gzip compression using the provided level and optional accepted media types.