1 year ago
A microservice has to fulfill many functional and nonfunctional requirements. And with all the other nonfunctional requirements, like protecting my service or scaling various parts independently, I love to work with Spring Cloud Gateway as this tiny and, IMHO, underrated tool is powerful, even with just a few lines of configuration. spring: cloud: gateway: routes: - id: locations uri: http://locationapi.example.com/ predicates: - Path=/v1/locations/** - id: weather uri: http://weatherapi.example.com/ predicates: - Path=/v1/weather/** spring: cloud: gateway: routes: - id: backend uri: http://backend.example.com predicates: - Path=/** filters: - name: RequestLogger 37 spring: cloud: gateway: routes: - id: slow-service uri: http://example.com/slow-service predicates: - Path=/slow/** filters: - name: CircuitBreaker args: name: slow-service fallbackUri: forward:/fallback/slow-service statusCodes: - name: ResponseTime args: baseName: slow-service timeout: 1000 tripwires: - id: slow-response threshold: 500 circuitBreaker: enabled: true timeout: 10000 ringBufferSizeInClosedState: 5 ringBufferSizeInHalfOpenState: 2 failureRateThreshold: 50 - id: fast-service uri: http://example.com/fast-service predicates: - Path=/fast/** - id: fallback-slow-service uri: forward:/fallback/slow-service predicates: - Path=/fallback/slow/**