api/handler/rpc: fix encoding of inner message (#1601)
* api/handler/rpc: fix encoding of inner message Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
0ccd618bb1
commit
cedaae65b7
16
rpc.go
16
rpc.go
@ -397,13 +397,29 @@ func requestPayload(r *http.Request) ([]byte, error) {
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var jsonbody map[string]interface{}
|
||||||
|
if json.Valid(bodybuf) {
|
||||||
|
if err = json.Unmarshal(bodybuf, &jsonbody); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
dstmap := make(map[string]interface{})
|
dstmap := make(map[string]interface{})
|
||||||
ps := strings.Split(bodydst, ".")
|
ps := strings.Split(bodydst, ".")
|
||||||
if len(ps) == 1 {
|
if len(ps) == 1 {
|
||||||
|
if jsonbody != nil {
|
||||||
|
dstmap[ps[0]] = jsonbody
|
||||||
|
} else {
|
||||||
|
// old unexpected behaviour
|
||||||
dstmap[ps[0]] = bodybuf
|
dstmap[ps[0]] = bodybuf
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
em := make(map[string]interface{})
|
em := make(map[string]interface{})
|
||||||
|
if jsonbody != nil {
|
||||||
|
em[ps[len(ps)-1]] = jsonbody
|
||||||
|
} else {
|
||||||
|
// old unexpected behaviour
|
||||||
em[ps[len(ps)-1]] = bodybuf
|
em[ps[len(ps)-1]] = bodybuf
|
||||||
|
}
|
||||||
for i := len(ps) - 2; i > 0; i-- {
|
for i := len(ps) - 2; i > 0; i-- {
|
||||||
nm := make(map[string]interface{})
|
nm := make(map[string]interface{})
|
||||||
nm[ps[i]] = em
|
nm[ps[i]] = em
|
||||||
|
Loading…
Reference in New Issue
Block a user