diff --git a/go.mod b/go.mod index 5c39b39..84d9d20 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 6d38c8a..91fb8b4 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/proto b/proto index 6616d01..15818ae 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 6616d01aac4a969d7b260733de3673b9ee15470a +Subproject commit 15818aeb2164a825e2003ff5d931d04c8a80e71a diff --git a/server/logic/gateway_logic_gen.go b/server/logic/gateway_logic_gen.go index 1228cd3..172a454 100644 --- a/server/logic/gateway_logic_gen.go +++ b/server/logic/gateway_logic_gen.go @@ -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 diff --git a/server/logic/gateway_meta.go b/server/logic/gateway_meta.go new file mode 100644 index 0000000..a99ab56 --- /dev/null +++ b/server/logic/gateway_meta.go @@ -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 +} diff --git a/server/main.go b/server/main.go index 5d980d1..409e7d6 100644 --- a/server/main.go +++ b/server/main.go @@ -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{}), )