From 96438e598d043ce0d83592d344fba5700a54af5b Mon Sep 17 00:00:00 2001 From: xing Date: Thu, 15 Sep 2022 23:22:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=90=AF=20gzip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 21 +++++++++++---------- route/route.go | 4 ++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 9b1b367..60e7f7b 100644 --- a/go.mod +++ b/go.mod @@ -10,22 +10,23 @@ 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 - github.com/go-playground/validator/v10 v10.10.0 // indirect - github.com/goccy/go-json v0.9.7 // indirect + github.com/go-playground/validator/v10 v10.11.0 // indirect + github.com/goccy/go-json v0.9.11 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/leodido/go-urn v1.2.1 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect - github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect + 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.1 // 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-20210711020723-a769d52b0f97 // indirect - golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect - golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 // indirect - golang.org/x/text v0.3.6 // indirect - google.golang.org/protobuf v1.28.0 // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect + golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect + golang.org/x/sys v0.0.0-20220913175220-63ea55921009 // indirect + golang.org/x/text v0.3.7 // indirect + google.golang.org/protobuf v1.28.1 // indirect ) diff --git a/route/route.go b/route/route.go index 814a87e..ec86979 100644 --- a/route/route.go +++ b/route/route.go @@ -1,6 +1,7 @@ package route import ( + "github.com/gin-contrib/gzip" "github.com/gin-gonic/gin" "github/fthvgb1/wp-go/middleware" "github/fthvgb1/wp-go/static" @@ -15,6 +16,9 @@ func SetupRouter() *gin.Engine { // gin.DisableConsoleColor() r := gin.Default() r.Use(middleware.SetStaticFileCache) + 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)