Documentation ¶
Overview ¶
Package httpgzip implements a http.Handler that compresses all HTTP operations with GZIP if the client supports it. It supports long-lived operations such as streams of data over HTTP, or short, regular HTTP operations.
gzh := httpgzip.NewHandler(myHandler) log.Fatal(http.ListenAndServe(":8080", gzh))
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultOnError ¶
func DefaultOnError(err error, w http.ResponseWriter, r *http.Request)
DefaultOnError logs errors to the standard log.Printf.
Types ¶
type GzipHandler ¶
type GzipHandler struct { // OnError is a hook you can provide to GzipHandler if you want to // handle cases where the handler can't process a request or has // encountered an error while processing it. // // If not set, will default to DefaultOnError OnError func(err error, w http.ResponseWriter, r *http.Request) // contains filtered or unexported fields }
GzipHandler wraps a handler. Before passing a HTTP transaction to the underlying handler, it will try to compress the response writer.
This handler supports both short lived and long lived HTTP, which makes it appropriate to serve streamed data.
func NewHandler ¶
func NewHandler(h http.Handler) *GzipHandler
NewHandler wraps h with a GzipHandler.
func (*GzipHandler) ServeHTTP ¶
func (g *GzipHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
Click to show internal directories.
Click to hide internal directories.