Skip to content

Commit 2c080d5

Browse files
committed
Merge branch 'release/0.3.0'
2 parents 09cfc2a + e3f4510 commit 2c080d5

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

control.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
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
9689
func (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)

router.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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
88
The router matches incoming requests by the request method and the path.
99
If a handle is registered for this path and method, the router delegates the

0 commit comments

Comments
 (0)