From 40ff2f79327f4cded98b05c2f00e8a6dd1e43b98 Mon Sep 17 00:00:00 2001 From: boyce Date: Sat, 26 Sep 2020 11:41:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A9=E5=B1=95rpc=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=A7=84=E8=8C=83=EF=BC=8C=E6=94=AF=E6=8C=81=E4=B8=8D=E5=B8=A6?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rpc/rpchandler.go | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/rpc/rpchandler.go b/rpc/rpchandler.go index 0798f08..99d4801 100644 --- a/rpc/rpchandler.go +++ b/rpc/rpchandler.go @@ -134,25 +134,28 @@ func (slf *RpcHandler) suitableMethods(method reflect.Method) error { return fmt.Errorf("%s The return parameter must be of type error!",method.Name) } - if typ.NumIn() > 4 { - return fmt.Errorf("%s The number of input arguments must be 1!",method.Name) + if typ.NumIn() <3 || typ.NumIn() > 4 { + return fmt.Errorf("%s Unsupported parameter format!",method.Name) } - if slf.isExportedOrBuiltinType(typ.In(1)) == false || slf.isExportedOrBuiltinType(typ.In(2)) == false{ - return fmt.Errorf("%s Unsupported parameter types!",method.Name) + //1.判断第一个参数 + var parIdx int = 1 + if typ.In(parIdx).String() == "rpc.IRawAdditionParam" { + parIdx += 1 + rpcMethodInfo.hashAdditionParam = true } - parIdx := 1 - if typ.NumIn() == 4 { - if slf.isExportedOrBuiltinType(typ.In(3)) == false { + for i:= parIdx ;i