I am currently implementing Spring Cloud would like to specify my routes into multiple files as an example below :
Initially we had one configuration having routes to A & B rest endpoints.
Spring Cloud Gateway fronts Rest Endpoint A and Rest Endpoint B
- Created YML 1 with routes to A and B (Refer below)
YML 1
----------------
spring:
cloud:
gateway:
routes:
- id: RouteA
uri: https://httpbin.org/
predicates:
- Path=/status/200
- id: RouteB
uri: https://httpbin.org/
predicates:
- Path=/status/400
A few days later I need to add routes to another Rest Endpoint C. I would not like to touch the original configuration (YML 1) instead would want to create a new YML for C and expect route C to append to original routing of A and B (similar to Apache Httpd WebProxy).
To have multiple YML I refer to suggestions from the below link : Spring Boot and multiple external configuration files
Spring Cloud Gateway fronts Rest Endpoint A, B and C
- Existing YML 1 with routes to A and B (Refer below)
- Created YML 2 with route to C (Refer below)
YML 1
----------------
spring:
cloud:
gateway:
routes:
- id: RouteA
uri: https://httpbin.org/
predicates:
- Path=/status/200
- id: RouteB
uri: https://httpbin.org/
predicates:
- Path=/status/400
YML 2
-----------------
spring:
cloud:
gateway:
routes:
- id: RouteC
uri: https://httpbin.org/
predicates:
- Path=/status/500
Expectation
-----------------------
spring:
cloud:
gateway:
routes:
- id: RouteA
uri: https://httpbin.org/
predicates:
- Path=/status/200
- id: RouteB
uri: https://httpbin.org/
predicates:
- Path=/status/400
- id: RouteC
uri: https://httpbin.org/
predicates:
- Path=/status/500
Actual Outcome
-------------------------
spring:
cloud:
gateway:
routes:
- id: RouteC
uri: https://httpbin.org/
predicates:
- Path=/status/500
Routes(A, B, C) do not get appended, instead it only picks up the latest configuration (YML 2 - Route C) in the property chain
If someone else has any bright ideas on how to implement this please suggest. All help and comments are more than welcome.