mirror of
https://github.com/smallnest/rpcx.git
synced 2025-10-31 11:26:56 +08:00
add PreCall and PostCall plugins of server
This commit is contained in:
@@ -529,12 +529,22 @@ func (s *Server) handleRequest(ctx context.Context, req *protocol.Message) (res
|
||||
|
||||
replyv := argsReplyPools.Get(mtype.ReplyType)
|
||||
|
||||
argv, err = s.Plugins.DoPreCall(ctx, argv)
|
||||
if err != nil {
|
||||
argsReplyPools.Put(mtype.ReplyType, replyv)
|
||||
return handleError(res, err)
|
||||
}
|
||||
|
||||
if mtype.ArgType.Kind() != reflect.Ptr {
|
||||
err = service.call(ctx, mtype, reflect.ValueOf(argv).Elem(), reflect.ValueOf(replyv))
|
||||
} else {
|
||||
err = service.call(ctx, mtype, reflect.ValueOf(argv), reflect.ValueOf(replyv))
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
replyv, err = s.Plugins.DoPostCall(ctx, argv, replyv)
|
||||
}
|
||||
|
||||
argsReplyPools.Put(mtype.ArgType, argv)
|
||||
if err != nil {
|
||||
argsReplyPools.Put(mtype.ReplyType, replyv)
|
||||
|
||||
Reference in New Issue
Block a user