improve panic information when a catch-all wildcard conflict occurs (#1529)

This commit is contained in:
田欧
2018-09-21 10:21:59 +08:00
committed by GitHub
parent f2cd3fcb2a
commit a210eea3bd
2 changed files with 51 additions and 2 deletions
+9 -2
View File
@@ -193,9 +193,16 @@ func (n *node) addRoute(path string, handlers HandlersChain) {
}
}
panic("path segment '" + path +
pathSeg := path
if n.nType != catchAll {
pathSeg = strings.SplitN(path, "/", 2)[0]
}
prefix := fullPath[:strings.Index(fullPath, pathSeg)] + n.path
panic("'" + pathSeg +
"' in new path '" + fullPath +
"' conflicts with existing wildcard '" + n.path +
"' in path '" + fullPath + "'")
"' in existing prefix '" + prefix +
"'")
}
c := path[0]