Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Middleware = fweight.MiddlewareFunc(func(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var flush func() defer func() { h.ServeHTTP(w, r) if flush != nil { flush() } }() encs := r.Header.Get("Accept-Encoding") if encs == "" { return } var compression Compression var encoding string rwm.RLock() for _, encoding = range strings.Split(strings.ToLower(encs), ",") { if compression = compressions[encoding]; compression != nil { break } } rwm.RUnlock() if compression == nil { return } ow := w uw := writer{ rw: ow, Compression: compression, } w = &uw w.Header().Set("Content-Encoding", encoding) w.Header().Set("Vary", "Accept-Encoding") flush = uw.flush }) })
Functions ¶
func Register ¶
func Register(name string, c Compression)
Registers a new compression with this package. Gzip and Flate are already registered. Name should be canonicalised to lower case.
Types ¶
type Compression ¶
type Compression func(io.Writer) Compressor
type Compressor ¶
func Flate ¶
func Flate(r io.Writer) (c Compressor)
func Gzip ¶
func Gzip(r io.Writer) Compressor
Click to show internal directories.
Click to hide internal directories.