Skip to content

Commit 75c62e5

Browse files
committed
url values
1 parent fa5ee35 commit 75c62e5

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

api-gateway/src/main/java/com/nipundas/api_gateway/routes/Routes.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.nipundas.api_gateway.routes;
22

3+
import org.springframework.beans.factory.annotation.Value;
34
import org.springframework.cloud.gateway.server.mvc.filter.CircuitBreakerFilterFunctions;
45
import org.springframework.cloud.gateway.server.mvc.handler.GatewayRouterFunctions;
56
import org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions;
@@ -20,11 +21,21 @@
2021
@Configuration
2122
public class Routes {
2223

24+
@Value("${product.service.url}")
25+
private String productServiceUrl;
26+
27+
@Value("${order.service.url}")
28+
private String orderServiceUrl;
29+
30+
@Value("${inventory.service.url}")
31+
private String inventoryServiceUrl;
32+
33+
2334
@Bean
2435
public RouterFunction<ServerResponse> productServiceRoute(){
2536
return route("product_service")
2637
.route(RequestPredicates.path("/api/product"),
27-
HandlerFunctions.http("http://localhost:8080"))
38+
HandlerFunctions.http(productServiceUrl))
2839
.filter(CircuitBreakerFilterFunctions.circuitBreaker("productServiceCircuitBreaker",
2940
URI.create("forward:/fallbackRoute")))
3041
.build();
@@ -34,7 +45,7 @@ public RouterFunction<ServerResponse> productServiceRoute(){
3445
public RouterFunction<ServerResponse> productServiceSwaggerRoute(){
3546
return route("product_service_swagger")
3647
.route(RequestPredicates.path("/aggregate/product-service/v3/api-docs"),
37-
HandlerFunctions.http("http://localhost:8080"))
48+
HandlerFunctions.http(productServiceUrl))
3849
.filter(CircuitBreakerFilterFunctions.circuitBreaker("productServiceSwaggerCircuitBreaker",
3950
URI.create("forward:/fallbackRoute")))
4051
.filter(setPath("/api-docs"))
@@ -45,7 +56,7 @@ public RouterFunction<ServerResponse> productServiceSwaggerRoute(){
4556
public RouterFunction<ServerResponse> orderServiceRoute(){
4657
return route("order_service")
4758
.route(RequestPredicates.path("/api/order"),
48-
HandlerFunctions.http("http://localhost:8081"))
59+
HandlerFunctions.http(orderServiceUrl))
4960
.filter(CircuitBreakerFilterFunctions.circuitBreaker("orderServiceCircuitBreaker",
5061
URI.create("forward:/fallbackRoute")))
5162
.build();
@@ -55,7 +66,7 @@ public RouterFunction<ServerResponse> orderServiceRoute(){
5566
public RouterFunction<ServerResponse> orderServiceSwaggerRoute(){
5667
return route("order_service_swagger")
5768
.route(RequestPredicates.path("/aggregate/order-service/v3/api-docs"),
58-
HandlerFunctions.http("http://localhost:8081"))
69+
HandlerFunctions.http(orderServiceUrl))
5970
.filter(CircuitBreakerFilterFunctions.circuitBreaker("orderServiceSwaggerCircuitBreaker",
6071
URI.create("forward:/fallbackRoute")))
6172
.filter(setPath("/api-docs"))
@@ -66,7 +77,7 @@ public RouterFunction<ServerResponse> orderServiceSwaggerRoute(){
6677
public RouterFunction<ServerResponse> inventoryServiceRoute(){
6778
return route("inventory_service")
6879
.route(RequestPredicates.path("/api/inventory"),
69-
HandlerFunctions.http("http://localhost:8082"))
80+
HandlerFunctions.http(inventoryServiceUrl))
7081
.filter(CircuitBreakerFilterFunctions.circuitBreaker("inventoryServiceCircuitBreaker",
7182
URI.create("forward:/fallbackRoute")))
7283
.build();
@@ -76,7 +87,7 @@ public RouterFunction<ServerResponse> inventoryServiceRoute(){
7687
public RouterFunction<ServerResponse> inventoryServiceSwaggerRoute(){
7788
return route("inventory_service_swagger")
7889
.route(RequestPredicates.path("/aggregate/inventory-service/v3/api-docs"),
79-
HandlerFunctions.http("http://localhost:8082"))
90+
HandlerFunctions.http(inventoryServiceUrl))
8091
.filter(CircuitBreakerFilterFunctions.circuitBreaker("inventoryServiceSwaggerCircuitBreaker",
8192
URI.create("forward:/fallbackRoute")))
8293
.filter(setPath("/api-docs"))

api-gateway/src/main/resources/application.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,9 @@ management.tracing.sampling.probability=1.0
4545

4646

4747

48-
loki.url=http://localhost:3100/loki/api/v1/push
48+
loki.url=http://localhost:3100/loki/api/v1/push
49+
50+
51+
product.service.url=http://localhost:8080
52+
order.service.url=http://localhost:8081
53+
inventory.service.url=http://localhost:8082

0 commit comments

Comments
 (0)