middleware

package
v0.17.133 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HttpHeaderContentLength   = "Content-Length"
	HttpHeaderAcceptEncoding  = "Accept-Encoding"
	HttpHeaderContentEncoding = "Content-Encoding"

	HttpEncodingGzip     = HttpEncoding("gzip")
	HttpEncodingBr       = HttpEncoding("br")
	HttpEncodingDeflate  = HttpEncoding("deflate")
	HttpEncodingIdentity = HttpEncoding("identity")
)

Variables

This section is empty.

Functions

func NewCompressionHandler

func NewCompressionHandler(next http.Handler) http.Handler

NewCompressionHandler will return a http.Handler that should be at the top of a response pipeline (i.e. before any other http.handlers that write). The returned handler will handle accept-encoding http header interpretation and provide a wrapped writer to all downstream http.handlers that will result in all written content to be compressed if possible.

The handler will alter the http responses content encoding header (specified algorithm), content body (compressed), and content length header (to match compressed body size). Attempting to set any of these values or alter the content response body (including writing more data) after the handler exits may cause issues for the receiving client.

Types

type HttpEncoding

type HttpEncoding string

Jump to

Keyboard shortcuts

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