From 0d5a68869dbc06db9fed6ed429a6b301e4b9f176 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Sun, 5 Mar 2023 22:19:58 +0800 Subject: [PATCH] fix: gateway conf doesn't work (#2968) --- gateway/config.go | 3 --- gateway/server.go | 1 - rest/internal/cors/handlers.go | 1 + 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/gateway/config.go b/gateway/config.go index 60c779d1..3d8e4dfd 100644 --- a/gateway/config.go +++ b/gateway/config.go @@ -1,8 +1,6 @@ package gateway import ( - "time" - "github.com/zeromicro/go-zero/rest" "github.com/zeromicro/go-zero/zrpc" ) @@ -12,7 +10,6 @@ type ( GatewayConf struct { rest.RestConf Upstreams []Upstream - Timeout time.Duration `json:",default=5s"` } // RouteMapping is a mapping between a gateway route and an upstream rpc method. diff --git a/gateway/server.go b/gateway/server.go index c6972709..c7a4d42c 100644 --- a/gateway/server.go +++ b/gateway/server.go @@ -38,7 +38,6 @@ func MustNewServer(c GatewayConf, opts ...Option) *Server { svr := &Server{ Server: rest.MustNewServer(c.RestConf), upstreams: c.Upstreams, - timeout: c.Timeout, } for _, opt := range opts { opt(svr) diff --git a/rest/internal/cors/handlers.go b/rest/internal/cors/handlers.go index 58187bcb..133b47dd 100644 --- a/rest/internal/cors/handlers.go +++ b/rest/internal/cors/handlers.go @@ -78,6 +78,7 @@ func checkAndSetHeaders(w http.ResponseWriter, r *http.Request, origins []string func isOriginAllowed(allows []string, origin string) bool { origin = strings.ToLower(origin) + for _, allow := range allows { if allow == allOrigins { return true