mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 09:00:20 +08:00
fix: gateway conf doesn't work (#2968)
This commit is contained in:
parent
d9d79e930d
commit
0d5a68869d
@ -1,8 +1,6 @@
|
|||||||
package gateway
|
package gateway
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/rest"
|
"github.com/zeromicro/go-zero/rest"
|
||||||
"github.com/zeromicro/go-zero/zrpc"
|
"github.com/zeromicro/go-zero/zrpc"
|
||||||
)
|
)
|
||||||
@ -12,7 +10,6 @@ type (
|
|||||||
GatewayConf struct {
|
GatewayConf struct {
|
||||||
rest.RestConf
|
rest.RestConf
|
||||||
Upstreams []Upstream
|
Upstreams []Upstream
|
||||||
Timeout time.Duration `json:",default=5s"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RouteMapping is a mapping between a gateway route and an upstream rpc method.
|
// RouteMapping is a mapping between a gateway route and an upstream rpc method.
|
||||||
|
@ -38,7 +38,6 @@ func MustNewServer(c GatewayConf, opts ...Option) *Server {
|
|||||||
svr := &Server{
|
svr := &Server{
|
||||||
Server: rest.MustNewServer(c.RestConf),
|
Server: rest.MustNewServer(c.RestConf),
|
||||||
upstreams: c.Upstreams,
|
upstreams: c.Upstreams,
|
||||||
timeout: c.Timeout,
|
|
||||||
}
|
}
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(svr)
|
opt(svr)
|
||||||
|
@ -78,6 +78,7 @@ func checkAndSetHeaders(w http.ResponseWriter, r *http.Request, origins []string
|
|||||||
|
|
||||||
func isOriginAllowed(allows []string, origin string) bool {
|
func isOriginAllowed(allows []string, origin string) bool {
|
||||||
origin = strings.ToLower(origin)
|
origin = strings.ToLower(origin)
|
||||||
|
|
||||||
for _, allow := range allows {
|
for _, allow := range allows {
|
||||||
if allow == allOrigins {
|
if allow == allOrigins {
|
||||||
return true
|
return true
|
||||||
|
Loading…
Reference in New Issue
Block a user