修复控制器和执行对象绑定'/'路由的问题

This commit is contained in:
john
2018-08-08 19:03:48 +08:00
parent 5ad9b272a6
commit e6d1a89d9f
2 changed files with 12 additions and 0 deletions

View File

@ -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,

View File

@ -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,