This commit is contained in:
crusader 2018-04-11 14:54:05 +09:00
parent 558c2aba94
commit 7dfdba6cf7

View File

@ -101,7 +101,8 @@ func (rr *restRegistry) Invoke(method string, params []string, leadingParams ...
var in []reflect.Value var in []reflect.Value
pValues, pInstances := methodSpec.ParamValues() pValues, pInstances := methodSpec.ParamValues()
var lParamLen int
lParamLen := 0
if nil != leadingParams { if nil != leadingParams {
lParamLen = len(leadingParams) lParamLen = len(leadingParams)
} }
@ -111,22 +112,10 @@ func (rr *restRegistry) Invoke(method string, params []string, leadingParams ...
return nil, err return nil, err
} }
for indexI := 0; indexI < lParamLen; indexI++ {
i := pInstances[indexI]
rv := reflect.ValueOf(i)
iv := reflect.ValueOf(leadingParams[indexI])
switch reflect.TypeOf(i).Elem().Kind() {
case reflect.Struct:
rv.Elem().Set(iv.Elem())
default:
rv.Elem().Set(iv)
}
}
pCount := len(pInstances) pCount := len(pInstances)
in = make([]reflect.Value, pCount+1) in = make([]reflect.Value, pCount+1)
for indexI := 0; indexI < pCount; indexI++ { for indexI := lParamLen; indexI < pCount; indexI++ {
if pValues[indexI].Type().Kind() == reflect.Ptr && pValues[indexI].Type().Elem().Kind() != reflect.Struct { if pValues[indexI].Type().Kind() == reflect.Ptr && pValues[indexI].Type().Elem().Kind() != reflect.Struct {
in[indexI+1] = reflect.Indirect(pValues[indexI]) in[indexI+1] = reflect.Indirect(pValues[indexI])
} else { } else {
@ -138,6 +127,10 @@ func (rr *restRegistry) Invoke(method string, params []string, leadingParams ...
} }
in[0] = serviceSpec.ReceiverValue() in[0] = serviceSpec.ReceiverValue()
for indexI := 0; indexI < lParamLen; indexI++ {
in[indexI+1] = reflect.ValueOf(leadingParams[indexI])
}
// Call the service method. // Call the service method.
returnValues := methodSpec.Call(in) returnValues := methodSpec.Call(in)