api/handler/rpc: dont change types of url fields (#1457)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
a7dd6d9004
commit
2c9996302d
10
rpc.go
10
rpc.go
@ -295,8 +295,9 @@ func requestPayload(r *http.Request) ([]byte, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
md = make(map[string]string)
|
md = make(map[string]string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate maximum
|
// allocate maximum
|
||||||
matches := make(map[string]string, len(md))
|
matches := make(map[string]interface{}, len(md))
|
||||||
|
|
||||||
// get fields from url path
|
// get fields from url path
|
||||||
for k, v := range md {
|
for k, v := range md {
|
||||||
@ -307,9 +308,12 @@ func requestPayload(r *http.Request) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// map of all fields
|
||||||
|
req := make(map[string]interface{}, len(md))
|
||||||
|
|
||||||
// get fields from url values
|
// get fields from url values
|
||||||
if len(r.URL.RawQuery) > 0 {
|
if len(r.URL.RawQuery) > 0 {
|
||||||
umd := make(map[string]string)
|
umd := make(map[string]interface{})
|
||||||
err = qson.Unmarshal(&umd, r.URL.RawQuery)
|
err = qson.Unmarshal(&umd, r.URL.RawQuery)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -322,7 +326,6 @@ func requestPayload(r *http.Request) ([]byte, error) {
|
|||||||
// restore context without fields
|
// restore context without fields
|
||||||
*r = *r.WithContext(metadata.NewContext(ctx, md))
|
*r = *r.WithContext(metadata.NewContext(ctx, md))
|
||||||
|
|
||||||
req := make(map[string]interface{}, len(md))
|
|
||||||
for k, v := range matches {
|
for k, v := range matches {
|
||||||
ps := strings.Split(k, ".")
|
ps := strings.Split(k, ".")
|
||||||
if len(ps) == 1 {
|
if len(ps) == 1 {
|
||||||
@ -342,6 +345,7 @@ func requestPayload(r *http.Request) ([]byte, error) {
|
|||||||
for vk, vv := range em {
|
for vk, vv := range em {
|
||||||
nm[vk] = vv
|
nm[vk] = vv
|
||||||
}
|
}
|
||||||
|
req[ps[0]] = nm
|
||||||
} else {
|
} else {
|
||||||
req[ps[0]] = em
|
req[ps[0]] = em
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user