ing
This commit is contained in:
parent
62fcae57f7
commit
d466ca204b
|
@ -3,7 +3,6 @@ package json
|
|||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"git.loafle.net/commons_go/rpc/encode"
|
||||
|
@ -177,20 +176,28 @@ func (scr *ServerCodecRequest) ReadParams(args []interface{}) error {
|
|||
// Data: scr.request.Params,
|
||||
// }
|
||||
// }
|
||||
jss := make([]json.RawMessage, len(args))
|
||||
if err := json.Unmarshal(*scr.request.Params, &jss); err != nil {
|
||||
log.Printf("err:%v", err)
|
||||
raws := make([]json.RawMessage, len(args))
|
||||
if err := json.Unmarshal(*scr.request.Params, &raws); err != nil {
|
||||
scr.err = &Error{
|
||||
Code: E_INVALID_REQ,
|
||||
Message: err.Error(),
|
||||
Data: scr.request.Params,
|
||||
}
|
||||
return scr.err
|
||||
}
|
||||
|
||||
for indexI := 0; indexI < len(args); indexI++ {
|
||||
js := jss[indexI]
|
||||
raw := raws[indexI]
|
||||
arg := args[indexI]
|
||||
if err := json.Unmarshal(js, &arg); err != nil {
|
||||
log.Printf("err:%v", err)
|
||||
if err := json.Unmarshal(raw, &arg); err != nil {
|
||||
scr.err = &Error{
|
||||
Code: E_INVALID_REQ,
|
||||
Message: err.Error(),
|
||||
Data: scr.request.Params,
|
||||
}
|
||||
return scr.err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return scr.err
|
||||
}
|
||||
|
|
|
@ -86,8 +86,11 @@ func (rr *rpcRegistry) Invoke(codec protocol.RegistryCodec) (result interface{},
|
|||
pCount := len(pInstances)
|
||||
in = make([]reflect.Value, pCount+1)
|
||||
for indexI := 0; indexI < pCount; indexI++ {
|
||||
if pValues[indexI].Type().Kind() == reflect.Ptr && pValues[indexI].Type().Elem().Kind() != reflect.Struct {
|
||||
in[indexI+1] = reflect.Indirect(pValues[indexI])
|
||||
} else {
|
||||
in[indexI+1] = pValues[indexI]
|
||||
//in[indexI+1] = reflect.ValueOf(pInstances[indexI]).Convert(methodSpec.paramTypes[indexI])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
in = make([]reflect.Value, 1)
|
||||
|
|
|
@ -54,11 +54,21 @@ func getValue(t reflect.Type) reflect.Value {
|
|||
rt = rt.Elem()
|
||||
}
|
||||
|
||||
rv := reflect.New(rt)
|
||||
if rt.Kind() != reflect.Struct {
|
||||
rv = reflect.Indirect(rv)
|
||||
}
|
||||
return rv
|
||||
// rv := reflect.New(rt)
|
||||
// if rt.Kind() != reflect.Struct {
|
||||
// rv = reflect.Indirect(rv)
|
||||
// }
|
||||
|
||||
// var rv reflect.Value
|
||||
|
||||
// switch rt.Kind() {
|
||||
// case reflect.Slice:
|
||||
// rv = reflect.New(reflect.SliceOf(rt.Elem()))
|
||||
// default:
|
||||
// rv = reflect.New(rt)
|
||||
// }
|
||||
|
||||
return reflect.New(rt)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user