1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 10:27:06 +00:00
Former-commit-id: 85c8b1e20da6e39485478025ef1b0f80ef953e4a
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-04-21 09:27:28 +03:00
parent 6c6de6b85d
commit 0cf5d5a4a3
4 changed files with 46 additions and 25 deletions

View File

@@ -463,7 +463,7 @@ func (api *APIBuilder) CreateRoutes(methods []string, relativePath string, handl
subdomain, path := splitSubdomainAndPath(fullpath)
// if allowMethods are empty, then simply register with the passed, main, method.
methods = append(api.allowMethods, methods...)
methods = removeDuplString(append(api.allowMethods, methods...))
routes := make([]*Route, len(methods))
@@ -487,6 +487,20 @@ func (api *APIBuilder) CreateRoutes(methods []string, relativePath string, handl
return routes
}
func removeDuplString(elements []string) (result []string) {
seen := make(map[string]struct{})
for v := range elements {
val := elements[v]
if _, ok := seen[val]; !ok {
seen[val] = struct{}{}
result = append(result, val)
}
}
return result
}
// Party groups routes which may have the same prefix and share same handlers,
// returns that new rich subrouter.
//