feat 拦截器取usn
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"git.hlsq.asia/mmorpg/service-common/discover"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/http/http_resp"
|
||||
"git.hlsq.asia/mmorpg/service-common/utils"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -56,8 +57,13 @@ func (s *Base) Init(addr string, port int32) {
|
||||
err = status.Error(codes.Internal, fmt.Sprintf("%v", r))
|
||||
}
|
||||
}()
|
||||
resp, err = handler(ctx, req)
|
||||
return
|
||||
if usnReq, ok := req.(interface{ GetUSN() string }); ok {
|
||||
usn := usnReq.GetUSN()
|
||||
if !utils.ShouldBindUsn(ctx, &usn) {
|
||||
return nil, http_resp.ParamError
|
||||
}
|
||||
}
|
||||
return handler(ctx, req)
|
||||
},
|
||||
),
|
||||
grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
|
||||
|
||||
Reference in New Issue
Block a user