File tree Expand file tree Collapse file tree 2 files changed +3
-10
lines changed
Expand file tree Collapse file tree 2 files changed +3
-10
lines changed Original file line number Diff line number Diff line change 88 "compress/gzip"
99 "encoding/json"
1010 "net/http"
11+ "strings"
1112 "time"
1213)
1314
@@ -34,9 +35,6 @@ type Control struct {
3435 // CompactJSON propery defines JSON output format (default is not compact)
3536 compactJSON bool
3637
37- // gzip propery defines compressed output
38- gzip bool
39-
4038 // Params is set of parameters
4139 Params []Param
4240
@@ -87,11 +85,6 @@ func (c *Control) CompactJSON(mode bool) {
8785 c .compactJSON = mode
8886}
8987
90- // UseGZIP defines compressed output
91- func (c * Control ) UseGZIP (mode bool ) {
92- c .gzip = mode
93- }
94-
9588// UseTimer allow caalculate elapsed time of request handling
9689func (c * Control ) UseTimer () {
9790 c .timer = time .Now ()
@@ -120,7 +113,7 @@ func (c *Control) Body(data interface{}) {
120113 }
121114 c .Writer .Header ().Add ("Content-type" , MIMEJSON )
122115 }
123- if c . gzip {
116+ if strings . Contains ( c . Request . Header . Get ( "Accept-Encoding" ), " gzip" ) {
124117 c .Writer .Header ().Add ("Content-Encoding" , "gzip" )
125118 c .Writer .WriteHeader (c .code )
126119 gz := gzip .NewWriter (c .Writer )
Original file line number Diff line number Diff line change 33// license that can be found in the LICENSE file.
44
55/*
6- Package router 0.2.12 provides fast HTTP request router.
6+ Package router 0.3.0 provides fast HTTP request router.
77
88The router matches incoming requests by the request method and the path.
99If a handle is registered for this path and method, the router delegates the
You can’t perform that action at this time.
0 commit comments