fixes for pathPrefix
This commit is contained in:
1 parent
e47db8325c
commit
e2d8bd206c
2 files changed
+7
-4
No files matched your search
+1
-1
@@ -1,13 +1,13 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"isp-gate-service/conf"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/integration-system/isp-lib/v2/structure"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/valyala/fasthttp"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/proxy/grpc"
|
||||
"isp-gate-service/proxy/health_check"
|
||||
|
||||
+6
-3
@@ -23,11 +23,11 @@ func InitRoutes(configs structure.RoutingConfig) {
|
||||
if len(backend.Endpoints) == 0 || backend.Address.Port == "" {
|
||||
continue
|
||||
}
|
||||
addEndpointsToMaps(backend.Endpoints, newAddressMap, newInnerAddressMap, newAuthUserAddressMap)
|
||||
addEndpointsToMaps(backend.Endpoints, "", newAddressMap, newInnerAddressMap, newAuthUserAddressMap)
|
||||
} else {
|
||||
for _, info := range backend.HandlersInfo {
|
||||
if info.Port != "" {
|
||||
addEndpointsToMaps(info.Endpoints, newAddressMap, newInnerAddressMap, newAuthUserAddressMap)
|
||||
addEndpointsToMaps(info.Endpoints, info.PathPrefix, newAddressMap, newInnerAddressMap, newAuthUserAddressMap)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,11 @@ func InitRoutes(configs structure.RoutingConfig) {
|
||||
AuthUserMethods = newAuthUserAddressMap
|
||||
}
|
||||
|
||||
func addEndpointsToMaps(endpoints []structure.EndpointDescriptor, newAddressMap map[string]bool, newInnerAddressMap map[string]bool, newAuthUserAddressMap map[string]bool) { //nolint
|
||||
func addEndpointsToMaps(endpoints []structure.EndpointDescriptor, pathPrefix string, newAddressMap map[string]bool, newInnerAddressMap map[string]bool, newAuthUserAddressMap map[string]bool) { //nolint
|
||||
for _, el := range endpoints {
|
||||
if pathPrefix != "" {
|
||||
el.Path = pathPrefix + "/" + el.Path
|
||||
}
|
||||
newAddressMap[el.Path] = true
|
||||
if el.Inner {
|
||||
newInnerAddressMap[el.Path] = true
|
||||
|
||||
Reference in new issue
Block a user