From 45f0c30e29bfc11fb8abacdf8a0c46398a8fe41f Mon Sep 17 00:00:00 2001 From: piupuer Date: Thu, 10 Oct 2024 14:30:32 +0800 Subject: [PATCH] [fix]bug --- go.mod | 4 +--- go.sum | 7 ++----- internal/server/grpc.go | 11 +++++------ internal/server/http.go | 11 +++++------ internal/server/middleware/header.go | 2 +- 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index 9a887eb..dfc7413 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/go-cinch/common/id v1.0.4 github.com/go-cinch/common/idempotent v1.0.4 github.com/go-cinch/common/jwt v1.0.3 - github.com/go-cinch/common/log v1.1.0 + github.com/go-cinch/common/log v1.1.1 github.com/go-cinch/common/middleware/i18n v1.0.5 github.com/go-cinch/common/middleware/logging v1.0.0 github.com/go-cinch/common/middleware/tenant v1.0.1 @@ -31,7 +31,6 @@ require ( github.com/golang-jwt/jwt/v4 v4.5.0 github.com/golang-module/carbon/v2 v2.3.12 github.com/google/wire v0.6.0 - github.com/gorilla/handlers v1.5.1 github.com/pkg/errors v0.9.1 github.com/redis/go-redis/v9 v9.2.1 github.com/thoas/go-funk v0.9.3 @@ -56,7 +55,6 @@ require ( github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/felixge/httpsnoop v1.0.1 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-cinch/common/migrate v1.0.4 // indirect github.com/go-cinch/common/nx v1.0.4 // indirect diff --git a/go.sum b/go.sum index 4964712..7841f7f 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,6 @@ github.com/envoyproxy/go-control-plane v0.12.1-0.20240621013728-1eb8caab5155 h1: github.com/envoyproxy/go-control-plane v0.12.1-0.20240621013728-1eb8caab5155/go.mod h1:5Wkq+JduFtdAXihLmeTJf+tRYIT4KBc2vPXDhwVo1pA= github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A= github.com/envoyproxy/protoc-gen-validate v1.0.4/go.mod h1:qys6tmnRsYrQqIhm2bvKZH4Blx/1gTIZ2UKVY1M+Yew= -github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= -github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= @@ -47,8 +45,9 @@ github.com/go-cinch/common/idempotent v1.0.4 h1:E/Ab+FHWjs1ym0U0mips6MyHEzucEded github.com/go-cinch/common/idempotent v1.0.4/go.mod h1:t4rBikz+RhpmF0tdGx+rm0Z1FzDy/6GtelgFB7RlaiY= github.com/go-cinch/common/jwt v1.0.3 h1:/jznvjevW+2KsmWm666O1NxkHLSfVmrjoWwkuWAqewk= github.com/go-cinch/common/jwt v1.0.3/go.mod h1:++p7kddWh9SyCYIYWEb5mfiR+ljKC3I5puiyjz7oGNs= -github.com/go-cinch/common/log v1.1.0 h1:Biq7f8fIoGeuAlqoRFer/ldmoQlAKQK1ZXWxw1qsKSc= github.com/go-cinch/common/log v1.1.0/go.mod h1:O4k/ArEdZS6c+YPKdESWJnVfhQ0QlwtIQ6mYxJZt5po= +github.com/go-cinch/common/log v1.1.1 h1:9ot3Qw4BKDfOZ7IC/3ZreuYJb953YD7pmM6ev6xT9FY= +github.com/go-cinch/common/log v1.1.1/go.mod h1:O4k/ArEdZS6c+YPKdESWJnVfhQ0QlwtIQ6mYxJZt5po= github.com/go-cinch/common/middleware/i18n v1.0.5 h1:SmxEMljqYF8xraaaa3KZgvNbKIE06ShQAZ34w87wkvs= github.com/go-cinch/common/middleware/i18n v1.0.5/go.mod h1:TiyZB9yzBx+giZqngOPQDXtDtYnqgMUgGqs4ebCgnQU= github.com/go-cinch/common/middleware/logging v1.0.0 h1:QElVRTRc67g2b/G/6TYtnS3YbtFKEcly8OOo6+usZQ8= @@ -138,8 +137,6 @@ github.com/google/wire v0.6.0 h1:HBkoIh4BdSxoyo9PveV8giw7ZsaBOvzWKfcg/6MrVwI= github.com/google/wire v0.6.0/go.mod h1:F4QhpQ9EDIdJ1Mbop/NZBRB+5yrR6qg3BnctaoUk6NA= github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 h1:f0n1xnMSmBLzVfsMMvriDyA75NB/oBgILX2GcHXIQzY= github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75/go.mod h1:g2644b03hfBX9Ov0ZBDgXXens4rxSxmqFBbhvKv2yVA= -github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= -github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= diff --git a/internal/server/grpc.go b/internal/server/grpc.go index 256601d..9cdb355 100644 --- a/internal/server/grpc.go +++ b/internal/server/grpc.go @@ -31,17 +31,16 @@ func NewGRPCServer( svc *service.AuthService, whitelist *biz.WhitelistUseCase, ) *grpc.Server { - middlewares := []middleware.Middleware{ - recovery.Recovery(), - tenantMiddleware.Tenant(), - ratelimit.Server(), - } + var middlewares []middleware.Middleware if c.Tracer.Enable { middlewares = append(middlewares, tracing.Server(), traceMiddleware.Id()) } - middlewares = append( middlewares, + recovery.Recovery(), + tenantMiddleware.Tenant(), + ratelimit.Server(), + localMiddleware.Header(), logging.Server(), i18nMiddleware.Translator(i18n.WithLanguage(language.Make(c.Server.Language)), i18n.WithFs(locales)), metadata.Server(), diff --git a/internal/server/http.go b/internal/server/http.go index ef9e196..a1a2865 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -32,17 +32,16 @@ func NewHTTPServer( svc *service.AuthService, whitelist *biz.WhitelistUseCase, ) *http.Server { - middlewares := []middleware.Middleware{ - recovery.Recovery(), - tenantMiddleware.Tenant(), - ratelimit.Server(), - localMiddleware.Header(), - } + var middlewares []middleware.Middleware if c.Tracer.Enable { middlewares = append(middlewares, tracing.Server(), traceMiddleware.Id()) } middlewares = append( middlewares, + recovery.Recovery(), + tenantMiddleware.Tenant(), + ratelimit.Server(), + localMiddleware.Header(), logging.Server(), i18nMiddleware.Translator(i18n.WithLanguage(language.Make(c.Server.Language)), i18n.WithFs(locales)), metadata.Server(), diff --git a/internal/server/middleware/header.go b/internal/server/middleware/header.go index 421e1d7..b29b62d 100644 --- a/internal/server/middleware/header.go +++ b/internal/server/middleware/header.go @@ -17,7 +17,7 @@ func Header() middleware.Middleware { tr.ReplyHeader().Set("x-content-type-options", "nosniff") tr.ReplyHeader().Set("x-xss-protection", "1; mode=block") tr.ReplyHeader().Set("x-frame-options", "deny") - tr.ReplyHeader().Set("Cache-Control", "private") + tr.ReplyHeader().Set("cache-control", "private") } } }