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

@@ -19,14 +19,12 @@ package pkg
import (
"fmt"
"github.com/jkaninda/goma-gateway/pkg/logger"
"gopkg.in/yaml.v3"
"os"
)
// loadExtraRoutes loads additional routes
func loadExtraRoutes(routePath string) ([]Route, error) {
logger.Info("Loading additional routes from %s", routePath)
yamlFiles, err := loadExtraFiles(routePath)
if err != nil {
return nil, fmt.Errorf("error loading extra files: %v", err)
@@ -44,12 +42,6 @@ func loadExtraRoutes(routePath string) ([]Route, error) {
}
extraRoutes = append(extraRoutes, ex.Routes...)
}
if len(extraRoutes) == 0 {
return nil, fmt.Errorf("no extra routes found in %s", routePath)
} else {
logger.Info("Loaded %d extra routes from %s", len(extraRoutes), routePath)
}
return extraRoutes, nil
}