From e6d1a89d9f525cbec7c8c75ced9ccc1996927e2e Mon Sep 17 00:00:00 2001 From: john Date: Wed, 8 Aug 2018 19:03:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A7=E5=88=B6=E5=99=A8?= =?UTF-8?q?=E5=92=8C=E6=89=A7=E8=A1=8C=E5=AF=B9=E8=B1=A1=E7=BB=91=E5=AE=9A?= =?UTF-8?q?'/'=E8=B7=AF=E7=94=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g/net/ghttp/ghttp_server_service_controller.go | 6 ++++++ g/net/ghttp/ghttp_server_service_object.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/g/net/ghttp/ghttp_server_service_controller.go b/g/net/ghttp/ghttp_server_service_controller.go index 825edbd57..336da858f 100644 --- a/g/net/ghttp/ghttp_server_service_controller.go +++ b/g/net/ghttp/ghttp_server_service_controller.go @@ -40,6 +40,9 @@ func (s *Server)BindController(pattern string, c Controller, methods...string) e p := key if strings.EqualFold(p[len(p) - 6:], "/index") { p = p[0 : len(p) - 6] + if len(p) == 0 { + p = "/" + } } m[p] = &handlerItem { ctype : v.Elem().Type(), @@ -75,6 +78,9 @@ func (s *Server)BindControllerMethod(pattern string, c Controller, methods strin p := key if strings.EqualFold(p[len(p) - 6:], "/index") { p = p[0 : len(p) - 6] + if len(p) == 0 { + p = "/" + } } m[p] = &handlerItem { ctype : t, diff --git a/g/net/ghttp/ghttp_server_service_object.go b/g/net/ghttp/ghttp_server_service_object.go index e3467b0be..52ebea54f 100644 --- a/g/net/ghttp/ghttp_server_service_object.go +++ b/g/net/ghttp/ghttp_server_service_object.go @@ -36,6 +36,9 @@ func (s *Server)BindObject(pattern string, obj interface{}, methods...string) er p := key if strings.EqualFold(p[len(p) - 6:], "/index") { p = p[0 : len(p) - 6] + if len(p) == 0 { + p = "/" + } } m[p] = &handlerItem { ctype : nil, @@ -71,6 +74,9 @@ func (s *Server)BindObjectMethod(pattern string, obj interface{}, methods string p := key if strings.EqualFold(p[len(p) - 6:], "/index") { p = p[0 : len(p) - 6] + if len(p) == 0 { + p = "/" + } } m[p] = &handlerItem { ctype : nil,