最新的gateway

This commit is contained in:
eson 2023-11-16 16:24:52 +08:00
parent 309b18a2b7
commit f7efb6faf3
6 changed files with 25 additions and 4 deletions

2
go.mod
View File

@ -47,4 +47,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)
replace fusen-basic v0.0.0 => gitee.com/fusenpack/fusen-basic v0.0.5-0.20231115062855-6f9b810c456b
replace fusen-basic v0.0.0 => gitee.com/fusenpack/fusen-basic v0.0.5-0.20231116042329-f02917634c5e

4
go.sum
View File

@ -1,6 +1,6 @@
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gitee.com/fusenpack/fusen-basic v0.0.5-0.20231115062855-6f9b810c456b h1:CXhj7d67CykbMvTQPGi+iOoDnbhqchEc3i4AYBSovlo=
gitee.com/fusenpack/fusen-basic v0.0.5-0.20231115062855-6f9b810c456b/go.mod h1:Zw6gt/0VwNmtG2Boqmo8+5H5AVuWsIVgCgp1ilkRyao=
gitee.com/fusenpack/fusen-basic v0.0.5-0.20231116042329-f02917634c5e h1:7AP0afu7/BedGvbl8yqVUCB1GuDYsO/omHZ8Qlu3gGw=
gitee.com/fusenpack/fusen-basic v0.0.5-0.20231116042329-f02917634c5e/go.mod h1:Zw6gt/0VwNmtG2Boqmo8+5H5AVuWsIVgCgp1ilkRyao=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=

2
proto

@ -1 +1 @@
Subproject commit 6616d01aac4a969d7b260733de3673b9ee15470a
Subproject commit 15818aeb2164a825e2003ff5d931d04c8a80e71a

View File

@ -16,6 +16,11 @@ func AutoRegisterHandler(ctx context.Context, mux *runtime.ServeMux, opts ...grp
return err
}
err = service.RegisterFsserviceHandlerClientNacos(ctx, mux, opts...)
if err != nil {
return err
}
err = service.RegisterInfoHandlerClientNacos(ctx, mux, opts...)
if err != nil {
return err

View File

@ -0,0 +1,15 @@
package logic
import (
"context"
"net/http"
"google.golang.org/grpc/metadata"
)
func PassMetadata(ctx context.Context, r *http.Request) metadata.MD {
headerValue := r.Header.Get("Debug-Token")
// 将值添加到 gRPC 元数据
md := metadata.Pairs("debug-token", headerValue)
return md
}

View File

@ -27,6 +27,7 @@ func main() {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
mux := runtime.NewServeMux(
runtime.WithMetadata(logic.PassMetadata),
runtime.WithForwardResponseOption(logic.ResponseHeaderMatcher),
runtime.WithMarshalerOption("*", &logic.EmptyMarshaler{}),
)