Browse Source

update auth

master
DengBiao 1 year ago
parent
commit
d7194a6e73
1 changed files with 4 additions and 11 deletions
  1. +4
    -11
      pkg/interceptor/interceptor.go

+ 4
- 11
pkg/interceptor/interceptor.go View File

@@ -25,23 +25,16 @@ func NewInterceptor(name string, urlWhitelist map[string]int) grpc.UnaryServerIn
logger.Logger.Debug(name, zap.Any("method", info.FullMethod), zap.Any("md", md), zap.Any("req", req),
zap.Any("resp", resp), zap.Error(err))

//resp, err = handleWithAuth(ctx, req, info, handler, urlWhitelist)
//logger.Logger.Debug(name, zap.Any("method", info.FullMethod), zap.Any("md", md), zap.Any("req", req),
// zap.Any("resp", resp), zap.Error(err))

s, _ := status.FromError(err)
if s.Code() != 0 && s.Code() < 1000 {
md, _ := metadata.FromIncomingContext(ctx)
logger.Logger.Error(name, zap.String("method", info.FullMethod), zap.Any("md", md), zap.Any("req", req),
zap.Any("resp", resp), zap.Error(err), zap.String("stack", gerrors.GetErrorStack(s)))
}

resp, err = handleWithAuth(ctx, req, info, handler, urlWhitelist)
logger.Logger.Debug(name, zap.Any("method", info.FullMethod), zap.Any("md", md), zap.Any("req", req),
zap.Any("resp", resp), zap.Error(err))

ss, _ := status.FromError(err)
if ss.Code() != 0 && ss.Code() < 1000 {
md, _ := metadata.FromIncomingContext(ctx)
logger.Logger.Error(name, zap.String("method", info.FullMethod), zap.Any("md", md), zap.Any("req", req),
zap.Any("resp", resp), zap.Error(err), zap.String("stack", gerrors.GetErrorStack(ss)))
}
return
}
}


Loading…
Cancel
Save