From c46003d882cfbb6ef2b8a264ea66f87ad53a607b Mon Sep 17 00:00:00 2001 From: dmitrijgulacenkov Date: Mon, 28 Sep 2020 14:53:32 +0300 Subject: [PATCH] linter issue fixes --- proxy/proxy.go | 23 +++++++++++------------ routing/routing.go | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index 256a2e1..b7ace51 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -73,7 +73,7 @@ func InitProxies(locations []conf.Location) (map[string]func([]structure.Address } func InitProxiesFromConfigs(configs structure.RoutingConfig) error { - for _, config := range configs { + for _, config := range configs { //nolint ip := config.Address.IP for protocol, info := range config.HandlersInfo { @@ -98,7 +98,7 @@ func InitProxiesFromConfigs(configs structure.RoutingConfig) error { } func getPathsFromEndpoints(endpoints []structure.EndpointDescriptor) []string { - var paths []string + paths := make([]string, len(endpoints)) for _, endpoint := range endpoints { paths = append(paths, endpoint.Path) } @@ -125,20 +125,19 @@ func makeProxy(protocol string, skipAuth, skipExistCheck bool) (Proxy, error) { func Find(path string) (Proxy, string) { for _, item := range store { - if item.pathPrefix == "" { - for _, iPath := range item.paths { - if path == iPath { - return item.proxy, path - } - if path == "/"+iPath { - return item.proxy, path[1:] - } - } - } else { + if item.pathPrefix != "" { if strings.HasPrefix(path, item.pathPrefix) { return item.proxy, getPathWithoutPrefix(path, item.pathPrefix) } } + for _, iPath := range item.paths { + if path == iPath { + return item.proxy, path + } + if path == "/"+iPath { + return item.proxy, path[1:] + } + } } return nil, "" } diff --git a/routing/routing.go b/routing/routing.go index c7771f1..a3e3fa0 100644 --- a/routing/routing.go +++ b/routing/routing.go @@ -37,7 +37,7 @@ func InitRoutes(configs structure.RoutingConfig) { AuthUserMethods = newAuthUserAddressMap } -func addEndpointsToMaps(endpoints []structure.EndpointDescriptor, newAddressMap map[string]bool, newInnerAddressMap map[string]bool, newAuthUserAddressMap map[string]bool) { +func addEndpointsToMaps(endpoints []structure.EndpointDescriptor, newAddressMap map[string]bool, newInnerAddressMap map[string]bool, newAuthUserAddressMap map[string]bool) { //nolint for _, el := range endpoints { newAddressMap[el.Path] = true if el.Inner {