diff --git a/control.go b/control.go index 98d4891..d84c3c2 100644 --- a/control.go +++ b/control.go @@ -8,6 +8,7 @@ import ( "compress/gzip" "encoding/json" "net/http" + "strings" "time" ) @@ -34,9 +35,6 @@ type Control struct { // CompactJSON propery defines JSON output format (default is not compact) compactJSON bool - // gzip propery defines compressed output - gzip bool - // Params is set of parameters Params []Param @@ -87,11 +85,6 @@ func (c *Control) CompactJSON(mode bool) { c.compactJSON = mode } -// UseGZIP defines compressed output -func (c *Control) UseGZIP(mode bool) { - c.gzip = mode -} - // UseTimer allow caalculate elapsed time of request handling func (c *Control) UseTimer() { c.timer = time.Now() @@ -120,7 +113,7 @@ func (c *Control) Body(data interface{}) { } c.Writer.Header().Add("Content-type", MIMEJSON) } - if c.gzip { + if strings.Contains(c.Request.Header.Get("Accept-Encoding"), "gzip") { c.Writer.Header().Add("Content-Encoding", "gzip") c.Writer.WriteHeader(c.code) gz := gzip.NewWriter(c.Writer) diff --git a/router.go b/router.go index dce0d69..90b2cc1 100644 --- a/router.go +++ b/router.go @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. /* -Package router 0.2.12 provides fast HTTP request router. +Package router 0.3.0 provides fast HTTP request router. The router matches incoming requests by the request method and the path. If a handle is registered for this path and method, the router delegates the