mirror of https://github.com/gofiber/fiber.git
Update router.go
parent
21e42ad126
commit
006bd188e5
10
router.go
10
router.go
|
@ -338,6 +338,7 @@ func (app *App) register(methods []string, pathRaw string, group *Group, handler
|
||||||
if pathRaw[0] != '/' {
|
if pathRaw[0] != '/' {
|
||||||
pathRaw = "/" + pathRaw
|
pathRaw = "/" + pathRaw
|
||||||
}
|
}
|
||||||
|
|
||||||
pathPretty := pathRaw
|
pathPretty := pathRaw
|
||||||
if !app.config.CaseSensitive {
|
if !app.config.CaseSensitive {
|
||||||
pathPretty = utils.ToLower(pathPretty)
|
pathPretty = utils.ToLower(pathPretty)
|
||||||
|
@ -345,11 +346,10 @@ func (app *App) register(methods []string, pathRaw string, group *Group, handler
|
||||||
if !app.config.StrictRouting && len(pathPretty) > 1 {
|
if !app.config.StrictRouting && len(pathPretty) > 1 {
|
||||||
pathPretty = utils.TrimRight(pathPretty, '/')
|
pathPretty = utils.TrimRight(pathPretty, '/')
|
||||||
}
|
}
|
||||||
pathClean := RemoveEscapeChar(pathPretty)
|
|
||||||
|
|
||||||
|
pathClean := RemoveEscapeChar(pathPretty)
|
||||||
parsedRaw := parseRoute(pathRaw, app.customConstraints...)
|
parsedRaw := parseRoute(pathRaw, app.customConstraints...)
|
||||||
parsedPretty := parseRoute(pathPretty, app.customConstraints...)
|
parsedPretty := parseRoute(pathPretty, app.customConstraints...)
|
||||||
|
|
||||||
isMount := group != nil && group.app != app
|
isMount := group != nil && group.app != app
|
||||||
|
|
||||||
for _, method := range methods {
|
for _, method := range methods {
|
||||||
|
@ -358,6 +358,12 @@ func (app *App) register(methods []string, pathRaw string, group *Group, handler
|
||||||
panic(fmt.Sprintf("add: invalid http method %s\n", method))
|
panic(fmt.Sprintf("add: invalid http method %s\n", method))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Duplicate Route Handling
|
||||||
|
if app.routeExists(method, pathRaw) {
|
||||||
|
matchPathFunc := func(r *Route) bool { return r.Path == pathRaw }
|
||||||
|
app.deleteRoute([]string{method}, matchPathFunc)
|
||||||
|
}
|
||||||
|
|
||||||
isUse := method == methodUse
|
isUse := method == methodUse
|
||||||
isStar := pathClean == "/*"
|
isStar := pathClean == "/*"
|
||||||
isRoot := pathClean == "/"
|
isRoot := pathClean == "/"
|
||||||
|
|
Loading…
Reference in New Issue