From 76ac6571bec712182f2ab7e3973c01a243363d44 Mon Sep 17 00:00:00 2001 From: dragongoose Date: Sun, 11 Jun 2023 18:14:34 -0400 Subject: [PATCH] Add GZIP compression support --- go.mod | 1 + go.sum | 2 ++ main.go | 2 ++ 3 files changed, 5 insertions(+) diff --git a/go.mod b/go.mod index 6dea575..c2dce62 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( github.com/bytedance/sonic v1.8.8 // indirect github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/gin-contrib/cors v1.4.0 // indirect + github.com/gin-contrib/gzip v0.0.6 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect diff --git a/go.sum b/go.sum index 2f1a611..df4a862 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g= github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs= +github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= +github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= diff --git a/main.go b/main.go index cc610c3..1950d0d 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "strings" + "github.com/gin-contrib/gzip" "github.com/gin-gonic/gin" ) @@ -48,6 +49,7 @@ func main() { } router := gin.New() router.Use(CORS()) + router.Use(gzip.Gzip(gzip.BestCompression)) router.Use(gin.Recovery()) go chat.BeginTwitchChatConnection()