From 12eb3ac63eb0a7773dd9a25ade711f30099da104 Mon Sep 17 00:00:00 2001 From: sunmoon <“i@liming.me”> Date: Thu, 10 Mar 2022 09:33:33 +0800 Subject: [PATCH 1/4] [fix bug] the default value of r.get is invalid --- net/ghttp/ghttp_request_param_request.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/ghttp/ghttp_request_param_request.go b/net/ghttp/ghttp_request_param_request.go index 8874fa79c..8f5531676 100644 --- a/net/ghttp/ghttp_request_param_request.go +++ b/net/ghttp/ghttp_request_param_request.go @@ -24,10 +24,10 @@ import ( // retrieved and overwrote in order of priority: router < query < body < form < custom. func (r *Request) GetRequest(key string, def ...interface{}) *gvar.Var { value := r.GetParam(key) - if value == nil { + if value.IsNil() { value = r.GetForm(key) } - if value == nil { + if value.IsNil() { r.parseBody() if len(r.bodyMap) > 0 { if v := r.bodyMap[key]; v != nil { @@ -35,13 +35,13 @@ func (r *Request) GetRequest(key string, def ...interface{}) *gvar.Var { } } } - if value == nil { + if value.IsNil() { value = r.GetQuery(key) } - if value == nil { + if value.IsNil() { value = r.GetRouter(key) } - if value != nil { + if value.IsNil() { return value } if len(def) > 0 { From 2471130f593eb721e3345e0144cc5d57c4ae6d01 Mon Sep 17 00:00:00 2001 From: sunmoon <“i@liming.me”> Date: Thu, 10 Mar 2022 09:52:45 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E9=87=8D=E8=B7=91ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- net/ghttp/ghttp_request_param_request.go | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ghttp/ghttp_request_param_request.go b/net/ghttp/ghttp_request_param_request.go index 8f5531676..c08fa0a8b 100644 --- a/net/ghttp/ghttp_request_param_request.go +++ b/net/ghttp/ghttp_request_param_request.go @@ -22,6 +22,7 @@ import ( // // Note that if there are multiple parameters with the same name, the parameters are // retrieved and overwrote in order of priority: router < query < body < form < custom. + func (r *Request) GetRequest(key string, def ...interface{}) *gvar.Var { value := r.GetParam(key) if value.IsNil() { From 581397947994b6a63f60058aba8c7b5a166fe564 Mon Sep 17 00:00:00 2001 From: sunmoon <“i@liming.me”> Date: Thu, 10 Mar 2022 14:32:06 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E9=87=8D=E8=B7=91ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- net/ghttp/ghttp_request_param_request.go | 1 - 1 file changed, 1 deletion(-) diff --git a/net/ghttp/ghttp_request_param_request.go b/net/ghttp/ghttp_request_param_request.go index c08fa0a8b..8f5531676 100644 --- a/net/ghttp/ghttp_request_param_request.go +++ b/net/ghttp/ghttp_request_param_request.go @@ -22,7 +22,6 @@ import ( // // Note that if there are multiple parameters with the same name, the parameters are // retrieved and overwrote in order of priority: router < query < body < form < custom. - func (r *Request) GetRequest(key string, def ...interface{}) *gvar.Var { value := r.GetParam(key) if value.IsNil() { From 7767bf4d5d875b6c9b64b49f5c51431376d71875 Mon Sep 17 00:00:00 2001 From: sunmoon <“i@liming.me”> Date: Fri, 11 Mar 2022 07:54:34 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E9=87=8D=E8=B7=91ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- net/ghttp/ghttp_request_param_request.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ghttp/ghttp_request_param_request.go b/net/ghttp/ghttp_request_param_request.go index 8f5531676..c594194e4 100644 --- a/net/ghttp/ghttp_request_param_request.go +++ b/net/ghttp/ghttp_request_param_request.go @@ -41,7 +41,7 @@ func (r *Request) GetRequest(key string, def ...interface{}) *gvar.Var { if value.IsNil() { value = r.GetRouter(key) } - if value.IsNil() { + if !value.IsNil() { return value } if len(def) > 0 {