mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 10:27:06 +00:00
minor
Former-commit-id: 85c8b1e20da6e39485478025ef1b0f80ef953e4a
This commit is contained in:
@@ -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.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user