This is an automated email from the ASF dual-hosted git repository.

baze pushed a commit to branch 1.4
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git

commit ca2538a7e8c374678fda25b13f892eaee9112803
Author: Patrick <dreamlike....@foxmail.com>
AuthorDate: Sat Apr 4 18:33:01 2020 +0800

    optimized code
---
 protocol/rest/server/rest_server.go | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/protocol/rest/server/rest_server.go 
b/protocol/rest/server/rest_server.go
index 60a75bc..fbd6fb7 100644
--- a/protocol/rest/server/rest_server.go
+++ b/protocol/rest/server/rest_server.go
@@ -160,11 +160,10 @@ func getArgsInterfaceFromRequest(req RestServerRequest, 
methodConfig *rest_confi
                }
                m := make(map[string]interface{})
                // TODO read as a slice
-               if err := req.ReadEntity(&m); err == nil {
-                       argsMap[methodConfig.Body] = m
-               } else {
+               if err := req.ReadEntity(&m); err != nil {
                        return nil, perrors.Errorf("[Go restful] Read body 
entity as map[string]interface{} error:%v", err)
                }
+               argsMap[methodConfig.Body] = m
        }
        args := make([]interface{}, maxKey+1)
        for k, v := range argsMap {
@@ -236,11 +235,10 @@ func assembleArgsFromBody(methodConfig 
*rest_config.RestMethodConfig, argsTypes
                                ni = n.Interface()
                        }
                }
-               if err := req.ReadEntity(&ni); err == nil {
-                       args[methodConfig.Body] = ni
-               } else {
+               if err := req.ReadEntity(&ni); err != nil {
                        return perrors.Errorf("[Go restful] Read body entity 
error, error is %v", perrors.WithStack(err))
                }
+               args[methodConfig.Body] = ni
        }
        return nil
 }

Reply via email to