chore: add route config check

This commit is contained in:
Jonas Kaninda
2024-11-18 12:58:49 +01:00
parent bc60fc78e0
commit b545027969
6 changed files with 131 additions and 76 deletions

View File

@@ -38,11 +38,17 @@ func (gatewayServer GatewayServer) Initialize() *mux.Router {
dynamicRoutes = gateway.Routes
// Load Extra Routes
if len(gateway.ExtraRoutes.Directory) != 0 {
logger.Info("Loading additional routes from %s", gateway.ExtraRoutes.Directory)
extraRoutes, err := loadExtraRoutes(gateway.ExtraRoutes.Directory)
if err != nil {
logger.Error("Error: %v", err.Error())
}
dynamicRoutes = append(dynamicRoutes, extraRoutes...)
if len(extraRoutes) == 0 {
logger.Info("no extra routes found in %s", gateway.ExtraRoutes.Directory)
} else {
dynamicRoutes = append(dynamicRoutes, extraRoutes...)
logger.Info("Loaded %d extra routes from %s", len(extraRoutes), gateway.ExtraRoutes.Directory)
}
}
// find duplicated route name
duplicates := findDuplicateRouteNames(dynamicRoutes)