mirror of
https://github.com/kataras/iris.git
synced 2026-01-05 11:17:03 +00:00
minor
Former-commit-id: 85c8b1e20da6e39485478025ef1b0f80ef953e4a
This commit is contained in:
@@ -11,7 +11,7 @@ https://husobee.github.io/golang/ip-address/2015/12/17/remote-ip-go.html request
|
||||
https://github.com/kataras/iris/issues/1453
|
||||
*/
|
||||
|
||||
//IPRange is a structure that holds the start and end of a range of IP Addresses.
|
||||
// IPRange is a structure that holds the start and end of a range of IP Addresses.
|
||||
type IPRange struct {
|
||||
Start net.IP `json:"start" yaml:"Start" toml"Start"`
|
||||
End net.IP `json:"end" yaml:"End" toml"End"`
|
||||
|
||||
@@ -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