This commit is contained in:
eson
2023-11-21 18:30:26 +08:00
parent ebcd27bbd5
commit 81df0950e3
5 changed files with 18 additions and 4 deletions

View File

@@ -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

View File

@@ -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()),
}