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] != '/' {
|
||||
pathRaw = "/" + pathRaw
|
||||
}
|
||||
|
||||
pathPretty := pathRaw
|
||||
if !app.config.CaseSensitive {
|
||||
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 {
|
||||
pathPretty = utils.TrimRight(pathPretty, '/')
|
||||
}
|
||||
pathClean := RemoveEscapeChar(pathPretty)
|
||||
|
||||
pathClean := RemoveEscapeChar(pathPretty)
|
||||
parsedRaw := parseRoute(pathRaw, app.customConstraints...)
|
||||
parsedPretty := parseRoute(pathPretty, app.customConstraints...)
|
||||
|
||||
isMount := group != nil && group.app != app
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
// 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
|
||||
isStar := pathClean == "/*"
|
||||
isRoot := pathClean == "/"
|
||||
|
|
Loading…
Reference in New Issue