fix: Sort routes by path in descending order for better proxying
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"slices"
|
"slices"
|
||||||
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
// init initializes prometheus metrics
|
// init initializes prometheus metrics
|
||||||
@@ -64,6 +65,10 @@ func (gatewayServer GatewayServer) Initialize() *mux.Router {
|
|||||||
if len(gateway.Redis.Addr) != 0 {
|
if len(gateway.Redis.Addr) != 0 {
|
||||||
redisBased = true
|
redisBased = true
|
||||||
}
|
}
|
||||||
|
// Sort routes by path in descending order
|
||||||
|
sort.Slice(dynamicRoutes, func(i, j int) bool {
|
||||||
|
return len(dynamicRoutes[i].Path) > len(dynamicRoutes[j].Path)
|
||||||
|
})
|
||||||
// Routes background healthcheck
|
// Routes background healthcheck
|
||||||
routesHealthCheck(dynamicRoutes)
|
routesHealthCheck(dynamicRoutes)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user