mirror of
https://github.com/go-micro/go-micro.git
synced 2024-11-24 08:02:32 +02:00
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
38cdb9cc2f
commit
90dd1f63c8
@ -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 {
|
||||||
dstmap[ps[0]] = bodybuf
|
if jsonbody != nil {
|
||||||
|
dstmap[ps[0]] = jsonbody
|
||||||
|
} else {
|
||||||
|
// old unexpected behaviour
|
||||||
|
dstmap[ps[0]] = bodybuf
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
em := make(map[string]interface{})
|
em := make(map[string]interface{})
|
||||||
em[ps[len(ps)-1]] = bodybuf
|
if jsonbody != nil {
|
||||||
|
em[ps[len(ps)-1]] = jsonbody
|
||||||
|
} else {
|
||||||
|
// old unexpected behaviour
|
||||||
|
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