Documentation ¶
Index ¶
Constants ¶
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 ¶
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