diff --git a/apigateway/src/main/java/com/springbootmicroservices/apigateway/config/GatewayConfig.java b/apigateway/src/main/java/com/springbootmicroservices/apigateway/config/GatewayConfig.java new file mode 100644 index 0000000..dae6f5a --- /dev/null +++ b/apigateway/src/main/java/com/springbootmicroservices/apigateway/config/GatewayConfig.java @@ -0,0 +1,30 @@ +package com.springbootmicroservices.apigateway.config; + +import org.springframework.cloud.gateway.route.RouteLocator; +import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Configuration class named {@link GatewayConfig} for setting up API Gateway routes. + */ +@Configuration +public class GatewayConfig { + + /** + * Configures the route locator to define the routing rules for the gateway. + * + * @param builder The RouteLocatorBuilder used to build the RouteLocator. + * @return A RouteLocator with the defined routes. + */ + @Bean + public RouteLocator routes(RouteLocatorBuilder builder) { + + return builder.routes() + .route("productservice", r -> r.path("/api/v1/products/**") + .uri("lb://productservice")) + .build(); + + } + +} diff --git a/productservice/src/main/java/com/springbootmicroservices/productservice/ProductserviceApplication.java b/productservice/src/main/java/com/springbootmicroservices/productservice/ProductserviceApplication.java index 729f3f5..1254aa3 100644 --- a/productservice/src/main/java/com/springbootmicroservices/productservice/ProductserviceApplication.java +++ b/productservice/src/main/java/com/springbootmicroservices/productservice/ProductserviceApplication.java @@ -5,7 +5,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient; /** - * The entry point for the Commonservice Spring Boot application. + * The entry point for the Product service Spring Boot application. * This application is a Eureka client that registers itself with a Eureka server. * The application is configured with the {@link SpringBootApplication} annotation. */