Retaining the Request's Path During Spring Cloud Gateway Failover

Viewed 258

Is there a way to externally configure Spring Cloud Gateway to failover to another data center? I'm thinking of something like this:

spring:
  cloud:
    gateway:
      routes:
      - id: test-service
        uri: lb://test-service:8085/
        predicates:
        - Path=/test-service/**
        filters:
        - StripPrefix=1
        - name: CircuitBreaker
          args:
            name: fallback
            fallbackUri: forward:/fallback
            #fallbackUri: forward:/fallback/test-service
      - id: fallback
        uri: http://${fallback_data_center}
        predicates:
        - Path=/fallback/**

---
spring:
  config:
    activate:
      on-profile: data_center_1
fallback_data_center: dc2.com

---
spring:
  config:
    activate:
      on-profile: data_center_2
fallback_data_center: dc1.com

The problem I run into is that the CircuitBreaker filter's fallbackUri parameter only supports forward schemed URIs. However, the path part of the request URL is overridden with the path in the forward URL. So there does not appear to be a way to failover with the path from the original request such as if this configuration had received a request of http://dc1.com/test-service/some/path without creating a configuration for every possible path.

0 Answers
Related