From 8a8742f86765688dda3fef4ee27220eed75053e2 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 1 Apr 2020 01:26:58 +0300 Subject: [PATCH] api/handler/rpc: dont change types of url fields (#1457) Signed-off-by: Vasiliy Tolstov --- api/handler/rpc/rpc.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/api/handler/rpc/rpc.go b/api/handler/rpc/rpc.go index 0aeceb43..543f5e8c 100644 --- a/api/handler/rpc/rpc.go +++ b/api/handler/rpc/rpc.go @@ -295,8 +295,9 @@ func requestPayload(r *http.Request) ([]byte, error) { if !ok { md = make(map[string]string) } + // allocate maximum - matches := make(map[string]string, len(md)) + matches := make(map[string]interface{}, len(md)) // get fields from url path 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 if len(r.URL.RawQuery) > 0 { - umd := make(map[string]string) + umd := make(map[string]interface{}) err = qson.Unmarshal(&umd, r.URL.RawQuery) if err != nil { return nil, err @@ -322,7 +326,6 @@ func requestPayload(r *http.Request) ([]byte, error) { // restore context without fields *r = *r.WithContext(metadata.NewContext(ctx, md)) - req := make(map[string]interface{}, len(md)) for k, v := range matches { ps := strings.Split(k, ".") if len(ps) == 1 { @@ -342,6 +345,7 @@ func requestPayload(r *http.Request) ([]byte, error) { for vk, vv := range em { nm[vk] = vv } + req[ps[0]] = nm } else { req[ps[0]] = em }