Skip to content

mocheryl/negroni-compress

Repository files navigation

negroni-compress

Content-Encoding middleware for Negroni.

Usage

package main

import (
    `fmt`
    `net/http`

    `github.com/codegangsta/negroni`
    `github.com/mocheryl/negroni-compress`
)

func main() {
    mux := http.NewServeMux()
    mux.HandleFunc(`/`, func(w http.ResponseWriter, req *http.Request) {
        w.Header().Set(`Content-Type`, `text/plain`)
        s := `Large enough compressiable content will be encoded based on client encoding support.`
        for i := 0; i <= 2048; i++ {
        	s += `.`
        }
        fmt.Fprintf(w, s)
    })

    n := negroni.Classic()
    n.Use(negronimodified.NewCompress())
    n.UseHandler(mux)
    n.Run(`:3000`)
}

See godoc.org for more information.

License

negroni-compress is released under the 3-Clause BSD license. See LICENSE.

About

Content-Encoding middleware for Negroni

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages