From 81df0950e32f677030d80ff6a01eac51e360b3fc Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Tue, 21 Nov 2023 18:30:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- go.sum | 4 ++-- proto | 2 +- server/logic/gateway_logic_gen.go | 5 +++++ server/main.go | 9 +++++++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index ad04f5e..8b98ec7 100644 --- a/go.mod +++ b/go.mod @@ -48,4 +48,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.20231117090447-740c4f28fda6 +replace fusen-basic v0.0.0 => gitee.com/fusenpack/fusen-basic v0.0.5-0.20231121101006-c27585d89386 diff --git a/go.sum b/go.sum index 4f722e6..929f271 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.20231117090447-740c4f28fda6 h1:u/iTiW6mFHp5/sqEPrO/JalEAur6UK5PKE7YXHJ+/0o= -gitee.com/fusenpack/fusen-basic v0.0.5-0.20231117090447-740c4f28fda6/go.mod h1:M6MEfmoOqiH6z2xfGb3WMd+jADI42flrUrNv2WoFE8A= +gitee.com/fusenpack/fusen-basic v0.0.5-0.20231121101006-c27585d89386 h1:SlQpIMqtLEiOQWmwGXxD00k8rMI2ACqgOCyTcw9fR/Q= +gitee.com/fusenpack/fusen-basic v0.0.5-0.20231121101006-c27585d89386/go.mod h1:M6MEfmoOqiH6z2xfGb3WMd+jADI42flrUrNv2WoFE8A= 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 52c1788..421740c 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 52c178825e99f266f148f361db587d06f88806fb +Subproject commit 421740c5cf009368523e2966e4c8ade4a316a6c8 diff --git a/server/logic/gateway_logic_gen.go b/server/logic/gateway_logic_gen.go index 1228cd3..0da2510 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.RegisterNotifyHandlerClientNacos(ctx, mux, opts...) + if err != nil { + return err + } + err = service.RegisterInfoHandlerClientNacos(ctx, mux, opts...) if err != nil { return err diff --git a/server/main.go b/server/main.go index 409e7d6..5ae3fe4 100644 --- a/server/main.go +++ b/server/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "log" "fusen-basic/env" "fusen-gateway/gen/go/service" @@ -27,12 +28,20 @@ func main() { ctx, cancel := context.WithCancel(ctx) defer cancel() mux := runtime.NewServeMux( + runtime.WithErrorHandler(func(ctx context.Context, sm *runtime.ServeMux, m runtime.Marshaler, w http.ResponseWriter, r *http.Request, err error) { + log.Println(err) + w.Write([]byte("\n" + err.Error())) + }), runtime.WithMetadata(logic.PassMetadata), runtime.WithForwardResponseOption(logic.ResponseHeaderMatcher), runtime.WithMarshalerOption("*", &logic.EmptyMarshaler{}), ) opts := []grpc.DialOption{ + grpc.WithUnaryInterceptor(func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { + log.Println(method) + return invoker(ctx, method, req, reply, cc, opts...) + }), grpc.WithTransportCredentials(insecure.NewCredentials()), }