feat: add routes loadblancing

This commit is contained in:
2024-11-09 10:59:17 +01:00
parent 1279f82bf9
commit 0f39ead97c
6 changed files with 35 additions and 3 deletions

View File

@@ -53,7 +53,10 @@ func (gatewayServer GatewayServer) Initialize() *mux.Router {
}
for _, route := range gateway.Routes {
if route.Path != "" {
if route.Destination == "" && len(route.Backends) == 0 {
logger.Fatal("Route %s : destination or backends should not be empty", route.Name)
}
// Apply middlewares to route
for _, mid := range route.Middlewares {
if mid != "" {
@@ -84,6 +87,7 @@ func (gatewayServer GatewayServer) Initialize() *mux.Router {
path: route.Path,
rewrite: route.Rewrite,
destination: route.Destination,
backends: route.Backends,
disableXForward: route.DisableHeaderXForward,
methods: route.Methods,
cors: route.Cors,
@@ -190,6 +194,7 @@ func (gatewayServer GatewayServer) Initialize() *mux.Router {
path: route.Path,
rewrite: route.Rewrite,
destination: route.Destination,
backends: route.Backends,
methods: route.Methods,
disableXForward: route.DisableHeaderXForward,
cors: route.Cors,