gateway反向代理导致的header信息重复BUG修复
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"github.com/gogf/gf/contrib/registry/consul/v2"
|
"github.com/gogf/gf/contrib/registry/consul/v2"
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/net/gsel"
|
||||||
"github.com/gogf/gf/v2/net/gsvc"
|
"github.com/gogf/gf/v2/net/gsvc"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,4 +19,5 @@ func init() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
gsvc.SetRegistry(registry)
|
gsvc.SetRegistry(registry)
|
||||||
|
gsel.SetBuilder(gsel.NewBuilderRoundRobin())
|
||||||
}
|
}
|
||||||
|
|||||||
14
http/http.go
14
http/http.go
@@ -8,10 +8,8 @@ import (
|
|||||||
"gitee.com/red-future---jilin-g/common/jaeger"
|
"gitee.com/red-future---jilin-g/common/jaeger"
|
||||||
"gitee.com/red-future---jilin-g/common/middleware"
|
"gitee.com/red-future---jilin-g/common/middleware"
|
||||||
"gitee.com/red-future---jilin-g/common/utils"
|
"gitee.com/red-future---jilin-g/common/utils"
|
||||||
"github.com/gogf/gf/contrib/registry/consul/v2"
|
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
"github.com/gogf/gf/v2/net/ghttp"
|
"github.com/gogf/gf/v2/net/ghttp"
|
||||||
"github.com/gogf/gf/v2/net/gsel"
|
|
||||||
"github.com/gogf/gf/v2/net/gsvc"
|
"github.com/gogf/gf/v2/net/gsvc"
|
||||||
"github.com/gogf/gf/v2/os/glog"
|
"github.com/gogf/gf/v2/os/glog"
|
||||||
"github.com/gogf/gf/v2/util/gconv"
|
"github.com/gogf/gf/v2/util/gconv"
|
||||||
@@ -65,17 +63,8 @@ func init() {
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`)
|
`)
|
||||||
Httpserver.BindMiddlewareDefault(ghttp.MiddlewareCORS, ghttp.MiddlewareHandlerResponse, middleware.Limiter, jaeger.NewTracer) //使用默认http返回结构
|
Httpserver.BindMiddlewareDefault(ghttp.MiddlewareHandlerResponse)
|
||||||
go Httpserver.Run()
|
go Httpserver.Run()
|
||||||
|
|
||||||
consulCfg, _ := g.Cfg().Get(context.Background(), "consul.address")
|
|
||||||
consulAddr := consulCfg.String()
|
|
||||||
registry, err := consul.New(consul.WithAddress(consulAddr))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
gsvc.SetRegistry(registry)
|
|
||||||
gsel.SetBuilder(gsel.NewBuilderRoundRobin())
|
|
||||||
Httpclient.SetDiscovery(gsvc.GetRegistry())
|
Httpclient.SetDiscovery(gsvc.GetRegistry())
|
||||||
}
|
}
|
||||||
func RouteRegister(controllers []interface{}) {
|
func RouteRegister(controllers []interface{}) {
|
||||||
@@ -86,6 +75,7 @@ func RouteRegister(controllers []interface{}) {
|
|||||||
return fmt.Sprintf("/%s", strings.ToLower(s))
|
return fmt.Sprintf("/%s", strings.ToLower(s))
|
||||||
})
|
})
|
||||||
Httpserver.Group(convertedStr, func(group *ghttp.RouterGroup) {
|
Httpserver.Group(convertedStr, func(group *ghttp.RouterGroup) {
|
||||||
|
group.Middleware(middleware.Limiter, jaeger.NewTracer)
|
||||||
group.Bind(t)
|
group.Bind(t)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user