Skip to content

Commit c1469c4

Browse files
authored
adding gzip middleware (#73)
1 parent aaa4c0c commit c1469c4

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ require (
1414
require (
1515
github.com/andybalholm/cascadia v1.3.1 // indirect
1616
github.com/davecgh/go-spew v1.1.1 // indirect
17+
github.com/gin-contrib/gzip v0.0.5
1718
github.com/gin-contrib/sse v0.1.0 // indirect
1819
github.com/go-playground/locales v0.14.0 // indirect
1920
github.com/go-playground/universal-translator v0.18.0 // indirect

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
66
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
77
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
88
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9+
github.com/gin-contrib/gzip v0.0.5 h1:mhnVU32YnnBh2LPH2iqRqsA/eR7SAqRaD388jL2s/j0=
10+
github.com/gin-contrib/gzip v0.0.5/go.mod h1:OPIK6HR0Um2vNmBUTlayD7qle4yVVRZT0PyhdUigrKk=
911
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
1012
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
13+
github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
1114
github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs=
1215
github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U=
1316
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=

src/webserver.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
_ "github.com/mantyr/go-charset/data"
1414

1515
"github.com/PuerkitoBio/goquery"
16+
"github.com/gin-contrib/gzip"
1617
"github.com/gin-gonic/gin"
1718
"github.com/go-resty/resty/v2"
1819
)
@@ -52,6 +53,9 @@ func runWebServer() {
5253

5354
router := gin.Default()
5455

56+
// gin middleware to enable GZIP support
57+
router.Use(gzip.Gzip(gzip.DefaultCompression))
58+
5559
// disable proxy feature of gin
5660
_ = router.SetTrustedProxies(nil)
5761

0 commit comments

Comments
 (0)