From cbbb7b8e03ca70e6396ffb4f1ec88860d0c5e9b0 Mon Sep 17 00:00:00 2001 From: xing Date: Fri, 16 Sep 2022 01:24:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=20gzip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 -- route/route.go | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 60e7f7b..0509fc6 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( ) require ( - 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.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect @@ -22,7 +21,6 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect - github.com/stretchr/testify v1.8.0 // indirect github.com/ugorji/go/codec v1.2.7 // indirect golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect diff --git a/route/route.go b/route/route.go index ec86979..57052de 100644 --- a/route/route.go +++ b/route/route.go @@ -1,7 +1,6 @@ package route import ( - "github.com/gin-contrib/gzip" "github.com/gin-gonic/gin" "github/fthvgb1/wp-go/middleware" "github/fthvgb1/wp-go/static" @@ -16,9 +15,10 @@ func SetupRouter() *gin.Engine { // gin.DisableConsoleColor() r := gin.Default() r.Use(middleware.SetStaticFileCache) - r.Use(gzip.Gzip(gzip.DefaultCompression, gzip.WithExcludedPaths([]string{ + //gzip 因为一般会用nginx做反代时自动使用gzip,所以go这边本身可以不用 + /*r.Use(gzip.Gzip(gzip.DefaultCompression, gzip.WithExcludedPaths([]string{ "/wp-includes/", "/wp-content/", - }))) + })))*/ r.SetFuncMap(template.FuncMap{ "unescaped": func(s string) interface{} { return template.HTML(s)