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,