diff --git a/reference/html/index.html b/reference/html/index.html index efa2a25d..72de683b 100644 --- a/reference/html/index.html +++ b/reference/html/index.html @@ -125,36 +125,35 @@ $(addBlockSwitches);
  • 5.3. AddResponseHeader GatewayFilter Factory
  • 5.4. DedupeResponseHeader GatewayFilter Factory
  • 5.5. Hystrix GatewayFilter Factory
  • -
  • 5.6. Spring Cloud CircuitBreaker GatewayFilter Factory
  • -
  • 5.7. FallbackHeaders GatewayFilter Factory
  • -
  • 5.8. MapRequestHeader GatewayFilter Factory
  • -
  • 5.9. PrefixPath GatewayFilter Factory
  • -
  • 5.10. PreserveHostHeader GatewayFilter Factory
  • -
  • 5.11. RequestRateLimiter GatewayFilter Factory +
  • 5.6. FallbackHeaders GatewayFilter Factory
  • +
  • 5.7. MapRequestHeader GatewayFilter Factory
  • +
  • 5.8. PrefixPath GatewayFilter Factory
  • +
  • 5.9. PreserveHostHeader GatewayFilter Factory
  • +
  • 5.10. RequestRateLimiter GatewayFilter Factory
  • -
  • 5.12. RedirectTo GatewayFilter Factory
  • -
  • 5.13. RemoveHopByHopHeadersFilter GatewayFilter Factory
  • -
  • 5.14. RemoveRequestHeader GatewayFilter Factory
  • -
  • 5.15. RemoveResponseHeader GatewayFilter Factory
  • -
  • 5.16. RemoveRequestParameter GatewayFilter Factory
  • -
  • 5.17. RewritePath GatewayFilter Factory
  • -
  • 5.18. RewriteLocationResponseHeader GatewayFilter Factory
  • -
  • 5.19. RewriteResponseHeader GatewayFilter Factory
  • -
  • 5.20. SaveSession GatewayFilter Factory
  • -
  • 5.21. SecureHeaders GatewayFilter Factory
  • -
  • 5.22. SetPath GatewayFilter Factory
  • -
  • 5.23. SetRequestHeader GatewayFilter Factory
  • -
  • 5.24. SetResponseHeader GatewayFilter Factory
  • -
  • 5.25. SetStatus GatewayFilter Factory
  • -
  • 5.26. StripPrefix GatewayFilter Factory
  • -
  • 5.27. Retry GatewayFilter Factory
  • -
  • 5.28. RequestSize GatewayFilter Factory
  • -
  • 5.29. Modify Request Body GatewayFilter Factory
  • -
  • 5.30. Modify Response Body GatewayFilter Factory
  • -
  • 5.31. Default Filters
  • +
  • 5.11. RedirectTo GatewayFilter Factory
  • +
  • 5.12. RemoveHopByHopHeadersFilter GatewayFilter Factory
  • +
  • 5.13. RemoveRequestHeader GatewayFilter Factory
  • +
  • 5.14. RemoveResponseHeader GatewayFilter Factory
  • +
  • 5.15. RemoveRequestParameter GatewayFilter Factory
  • +
  • 5.16. RewritePath GatewayFilter Factory
  • +
  • 5.17. RewriteLocationResponseHeader GatewayFilter Factory
  • +
  • 5.18. RewriteResponseHeader GatewayFilter Factory
  • +
  • 5.19. SaveSession GatewayFilter Factory
  • +
  • 5.20. SecureHeaders GatewayFilter Factory
  • +
  • 5.21. SetPath GatewayFilter Factory
  • +
  • 5.22. SetRequestHeader GatewayFilter Factory
  • +
  • 5.23. SetResponseHeader GatewayFilter Factory
  • +
  • 5.24. SetStatus GatewayFilter Factory
  • +
  • 5.25. StripPrefix GatewayFilter Factory
  • +
  • 5.26. Retry GatewayFilter Factory
  • +
  • 5.27. RequestSize GatewayFilter Factory
  • +
  • 5.28. Modify Request Body GatewayFilter Factory
  • +
  • 5.29. Modify Response Body GatewayFilter Factory
  • +
  • 5.30. Default Filters
  • 6. Global Filters @@ -851,19 +850,6 @@ If two hops of trusted infrastructure are required before Spring Cloud Gateway i

    5.5. Hystrix GatewayFilter Factory

    -
    - - - - - -
    - - -Netflix has put Hystrix in maintenance mode. It is suggested you use the Spring Cloud CircuitBreaker -Gateway Filter with Resilience4J as support for Hystrix will be removed in a future release. -
    -

    Hystrix is a library from Netflix that implements the circuit breaker pattern. The Hystrix GatewayFilter allows you to introduce circuit breakers to your gateway routes, protecting your services from cascading failures and allowing you to provide fallback responses in the event of downstream failures.

    @@ -969,125 +955,9 @@ on it in the FallbackHeaders GatewayFilter Factory
    -

    5.6. Spring Cloud CircuitBreaker GatewayFilter Factory

    +

    5.6. FallbackHeaders GatewayFilter Factory

    -

    The Spring Cloud CircuitBreaker filter factory leverages the Spring Cloud CircuitBreaker APIs to wrap Gateway routes in -a circuit breaker. Spring Cloud CircuitBreaker supports two libraries which can be used with Spring Cloud Gateway, Hystrix -and Resilience4J. Since Netflix has places Hystrix in maintenance only mode we suggest you use Resilience4J.

    -
    -
    -

    To enable the Spring Cloud CircuitBreaker filter you will need to either place spring-cloud-starter-circuitbreaker-reactor-resilience4j or -spring-cloud-starter-netflix-hystrix on the classpath.

    -
    -
    -
    application.yml
    -
    -
    spring:
    -  cloud:
    -    gateway:
    -      routes:
    -      - id: circuitbreaker_route
    -        uri: https://example.org
    -        filters:
    -        - CircuitBreaker=myCircuitBreaker
    -
    -
    -
    -

    To configure the circuit breaker, see the configuration for the underlying circuit breaker implementation you are using.

    -
    - -
    -

    The Spring Cloud CircuitBreaker filter can also accept an optional fallbackUri parameter. Currently, only forward: schemed URIs are supported. If the fallback is called, the request will be forwarded to the controller matched by the URI.

    -
    -
    -
    application.yml
    -
    -
    spring:
    -  cloud:
    -    gateway:
    -      routes:
    -      - id: circuitbreaker_route
    -        uri: lb://backing-service:8088
    -        predicates:
    -        - Path=/consumingServiceEndpoint
    -        filters:
    -        - name: CircuitBreaker
    -          args:
    -            name: myCircuitBreaker
    -            fallbackUri: forward:/inCaseOfFailureUseThis
    -        - RewritePath=/consumingServiceEndpoint, /backingServiceEndpoint
    -
    -
    -
    -
    Application.java
    -
    -
    @Bean
    -public RouteLocator routes(RouteLocatorBuilder builder) {
    -    return builder.routes()
    -        .route("circuitbreaker_route", r -> r.path("/consumingServiceEndpoint")
    -            .filters(f -> f.circuitBreaker(c -> c.name("myCircuitBreaker").fallbackUri("forward:/inCaseOfFailureUseThis"))
    -                .rewritePath("/consumingServiceEndpoint", "/backingServiceEndpoint")).uri("lb://backing-service:8088")
    -        .build();
    -}
    -
    -
    -
    -

    This will forward to the /inCaseofFailureUseThis URI when the circuit breaker fallback is called. Note that this example also demonstrates (optional) Spring Cloud Netflix Ribbon load-balancing via the lb prefix on the destination URI.

    -
    -
    -

    The primary scenario is to use the fallbackUri to an internal controller or handler within the gateway app. -However, it is also possible to reroute the request to a controller or handler in an external application, like so:

    -
    -
    -
    application.yml
    -
    -
    spring:
    -  cloud:
    -    gateway:
    -      routes:
    -      - id: ingredients
    -        uri: lb://ingredients
    -        predicates:
    -        - Path=//ingredients/**
    -        filters:
    -        - name: CircuitBreaker
    -          args:
    -            name: fetchIngredients
    -            fallbackUri: forward:/fallback
    -      - id: ingredients-fallback
    -        uri: http://localhost:9994
    -        predicates:
    -        - Path=/fallback
    -
    -
    -
    -

    In this example, there is no fallback endpoint or handler in the gateway application, however, there is one in another -app, registered under localhost:9994.

    -
    -
    -

    In case of the request being forwarded to fallback, the Spring Cloud CircuitBreaker Gateway filter also provides the Throwable that has -caused it. It’s added to the ServerWebExchange as the -ServerWebExchangeUtils.CIRCUITBREAKER_EXECUTION_EXCEPTION_ATTR attribute that can be used when -handling the fallback within the gateway app.

    -
    -
    -

    For the external controller/handler scenario, headers can be added with exception details. You can find more information -on it in the FallbackHeaders GatewayFilter Factory section.

    -
    -
    -
    -

    5.7. FallbackHeaders GatewayFilter Factory

    -
    -

    The FallbackHeaders factory allows you to add Hystrix or Spring Cloud CircuitBreaker execution exception details in headers of a request forwarded to +

    The FallbackHeaders factory allows you to add Hystrix execution exception details in headers of a request forwarded to a fallbackUri in an external application, like in the following scenario:

    @@ -1102,7 +972,7 @@ a fallbackUri in an external application, like in the following sce predicates: - Path=//ingredients/** filters: - - name: CircuitBreaker + - name: Hystrix args: name: fetchIngredients fallbackUri: forward:/fallback @@ -1117,7 +987,7 @@ a fallbackUri in an external application, like in the following sce
    -

    In this example, after an execution exception occurs while running the circuit breaker, the request will be forwarded to +

    In this example, after an execution exception occurs while running the HystrixCommand, the request will be forwarded to the fallback endpoint or handler in an app running on localhost:9994. The headers with the exception type, message and -if available- root cause exception type and message will be added to that request by the FallbackHeaders filter.

    @@ -1142,12 +1012,11 @@ their default values:

    -

    For more information of circuit beakers and the Gateway see the Hystrix GatewayFilter Factory section or -Spring Cloud CircuitBreaker Factory section.

    +

    You can find more information on how Hystrix works with Gateway in the Hystrix GatewayFilter Factory section.

    -

    5.8. MapRequestHeader GatewayFilter Factory

    +

    5.7. MapRequestHeader GatewayFilter Factory

    The MapRequestHeader GatewayFilter Factory takes 'fromHeader' and 'toHeader' parameters. It creates a new named header (toHeader) and the value is extracted out of an existing named header (fromHeader) from the incoming http request. If the input header does not exist then the filter has no impact. If the new named header already exists then it’s values will be augmented with the new values.

    @@ -1169,7 +1038,7 @@ their default values:

    -

    5.9. PrefixPath GatewayFilter Factory

    +

    5.8. PrefixPath GatewayFilter Factory

    The PrefixPath GatewayFilter Factory takes a single prefix parameter.

    @@ -1191,7 +1060,7 @@ their default values:

    -

    5.10. PreserveHostHeader GatewayFilter Factory

    +

    5.9. PreserveHostHeader GatewayFilter Factory

    The PreserveHostHeader GatewayFilter Factory has no parameters. This filter sets a request attribute that the routing filter will inspect to determine if the original host header should be sent, rather than the host header determined by the http client.

    @@ -1210,7 +1079,7 @@ their default values:

    -

    5.11. RequestRateLimiter GatewayFilter Factory

    +

    5.10. RequestRateLimiter GatewayFilter Factory

    The RequestRateLimiter GatewayFilter Factory is uses a RateLimiter implementation to determine if the current request is allowed to proceed. If it is not, a status of HTTP 429 - Too Many Requests (by default) is returned.

    @@ -1257,7 +1126,7 @@ spring.cloud.gateway.routes[0].filters[0]=RequestRateLimiter=2, 2, #{@userkeyres
    -

    5.11.1. Redis RateLimiter

    +

    5.10.1. Redis RateLimiter

    The redis implementation is based off of work done at Stripe. It requires the use of the spring-boot-starter-data-redis-reactive Spring Boot starter.

    @@ -1323,7 +1192,7 @@ KeyResolver userKeyResolver() {
    -

    5.12. RedirectTo GatewayFilter Factory

    +

    5.11. RedirectTo GatewayFilter Factory

    The RedirectTo GatewayFilter Factory takes a status and a url parameter. The status should be a 300 series redirect http code, such as 301. The url should be a valid url. This will be the value of the Location header.

    @@ -1345,7 +1214,7 @@ KeyResolver userKeyResolver() {
    -

    5.13. RemoveHopByHopHeadersFilter GatewayFilter Factory

    +

    5.12. RemoveHopByHopHeadersFilter GatewayFilter Factory

    The RemoveHopByHopHeadersFilter GatewayFilter Factory removes headers from forwarded requests. The default list of headers that is removed comes from the IETF.

    @@ -1383,7 +1252,7 @@ KeyResolver userKeyResolver() {
    -

    5.14. RemoveRequestHeader GatewayFilter Factory

    +

    5.13. RemoveRequestHeader GatewayFilter Factory

    The RemoveRequestHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.

    @@ -1405,7 +1274,7 @@ KeyResolver userKeyResolver() {
    -

    5.15. RemoveResponseHeader GatewayFilter Factory

    +

    5.14. RemoveResponseHeader GatewayFilter Factory

    The RemoveResponseHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.

    @@ -1432,7 +1301,7 @@ and have it applied to all routes.

    -

    5.16. RemoveRequestParameter GatewayFilter Factory

    +

    5.15. RemoveRequestParameter GatewayFilter Factory

    The RemoveRequestParameter GatewayFilter Factory takes a name parameter. It is the name of the query parameter to be removed.

    @@ -1454,7 +1323,7 @@ and have it applied to all routes.

    -

    5.17. RewritePath GatewayFilter Factory

    +

    5.16. RewritePath GatewayFilter Factory

    The RewritePath GatewayFilter Factory takes a path regexp parameter and a replacement parameter. This uses Java regular expressions for a flexible way to rewrite the request path.

    @@ -1478,7 +1347,7 @@ and have it applied to all routes.

    -

    5.18. RewriteLocationResponseHeader GatewayFilter Factory

    +

    5.17. RewriteLocationResponseHeader GatewayFilter Factory

    The RewriteLocationResponseHeader GatewayFilter Factory modifies the value of Location response header, usually to get rid of backend specific details. It takes stripVersionMode, locationHeaderName, hostValue, and protocolsRegex parameters.

    @@ -1522,7 +1391,7 @@ and have it applied to all routes.

    -

    5.19. RewriteResponseHeader GatewayFilter Factory

    +

    5.18. RewriteResponseHeader GatewayFilter Factory

    The RewriteResponseHeader GatewayFilter Factory takes name, regexp, and replacement parameters. It uses Java regular expressions for a flexible way to rewrite the response header value.

    @@ -1544,7 +1413,7 @@ and have it applied to all routes.

    -

    5.20. SaveSession GatewayFilter Factory

    +

    5.19. SaveSession GatewayFilter Factory

    The SaveSession GatewayFilter Factory forces a WebSession::save operation before forwarding the call downstream. This is of particular use when using something like Spring Session with a lazy data store and need to ensure the session state has been saved before making the forwarded call.

    @@ -1569,7 +1438,7 @@ using something like Spring
    -

    5.21. SecureHeaders GatewayFilter Factory

    +

    5.20. SecureHeaders GatewayFilter Factory

    The SecureHeaders GatewayFilter Factory adds a number of headers to the response at the recommendation from this blog post.

    @@ -1643,7 +1512,7 @@ using something like Spring
    -

    5.22. SetPath GatewayFilter Factory

    +

    5.21. SetPath GatewayFilter Factory

    The SetPath GatewayFilter Factory takes a path template parameter. It offers a simple way to manipulate the request path by allowing templated segments of the path. This uses the uri templates from Spring Framework. Multiple matching segments are allowed.

    @@ -1667,7 +1536,7 @@ using something like Spring
    -

    5.23. SetRequestHeader GatewayFilter Factory

    +

    5.22. SetRequestHeader GatewayFilter Factory

    The SetRequestHeader GatewayFilter Factory takes name and value parameters.

    @@ -1707,7 +1576,7 @@ using something like Spring
    -

    5.24. SetResponseHeader GatewayFilter Factory

    +

    5.23. SetResponseHeader GatewayFilter Factory

    The SetResponseHeader GatewayFilter Factory takes name and value parameters.

    @@ -1747,7 +1616,7 @@ using something like Spring
    -

    5.25. SetStatus GatewayFilter Factory

    +

    5.24. SetStatus GatewayFilter Factory

    The SetStatus GatewayFilter Factory takes a single status parameter. It must be a valid Spring HttpStatus. It may be the integer value 404 or the string representation of the enumeration NOT_FOUND.

    @@ -1786,7 +1655,7 @@ using something like Spring
    -

    5.26. StripPrefix GatewayFilter Factory

    +

    5.25. StripPrefix GatewayFilter Factory

    The StripPrefix GatewayFilter Factory takes one parameter, parts. The parts parameter indicated the number of parts in the path to strip from the request before sending it downstream.

    @@ -1810,7 +1679,7 @@ using something like Spring
    -

    5.27. Retry GatewayFilter Factory

    +

    5.26. Retry GatewayFilter Factory

    The Retry GatewayFilter Factory support following set of parameters:

    @@ -1909,7 +1778,7 @@ When using the retry filter with a forward: prefixed URL, the targe
    -

    5.28. RequestSize GatewayFilter Factory

    +

    5.27. RequestSize GatewayFilter Factory

    The RequestSize GatewayFilter Factory can restrict a request from reaching the downstream service , when the request size is greater than the permissible limit. The filter takes RequestSize as parameter which is the permissible size limit of the request defined in bytes.

    @@ -1950,7 +1819,7 @@ The default Request size will be set to 5 MB if not provided as filter argument
    -

    5.29. Modify Request Body GatewayFilter Factory

    +

    5.28. Modify Request Body GatewayFilter Factory

    This filter is considered BETA and the API may change in the future

    @@ -2002,7 +1871,7 @@ static class Hello {
    -

    5.30. Modify Response Body GatewayFilter Factory

    +

    5.29. Modify Response Body GatewayFilter Factory

    This filter is considered BETA and the API may change in the future

    @@ -2036,7 +1905,7 @@ public RouteLocator routes(RouteLocatorBuilder builder) {
    -

    5.31. Default Filters

    +

    5.30. Default Filters

    If you would like to add a filter and apply it to all routes you can use spring.cloud.gateway.default-filters. This property takes a list of filters

    diff --git a/reference/html/spring-cloud-gateway.html b/reference/html/spring-cloud-gateway.html index efa2a25d..72de683b 100644 --- a/reference/html/spring-cloud-gateway.html +++ b/reference/html/spring-cloud-gateway.html @@ -125,36 +125,35 @@ $(addBlockSwitches);
  • 5.3. AddResponseHeader GatewayFilter Factory
  • 5.4. DedupeResponseHeader GatewayFilter Factory
  • 5.5. Hystrix GatewayFilter Factory
  • -
  • 5.6. Spring Cloud CircuitBreaker GatewayFilter Factory
  • -
  • 5.7. FallbackHeaders GatewayFilter Factory
  • -
  • 5.8. MapRequestHeader GatewayFilter Factory
  • -
  • 5.9. PrefixPath GatewayFilter Factory
  • -
  • 5.10. PreserveHostHeader GatewayFilter Factory
  • -
  • 5.11. RequestRateLimiter GatewayFilter Factory +
  • 5.6. FallbackHeaders GatewayFilter Factory
  • +
  • 5.7. MapRequestHeader GatewayFilter Factory
  • +
  • 5.8. PrefixPath GatewayFilter Factory
  • +
  • 5.9. PreserveHostHeader GatewayFilter Factory
  • +
  • 5.10. RequestRateLimiter GatewayFilter Factory
  • -
  • 5.12. RedirectTo GatewayFilter Factory
  • -
  • 5.13. RemoveHopByHopHeadersFilter GatewayFilter Factory
  • -
  • 5.14. RemoveRequestHeader GatewayFilter Factory
  • -
  • 5.15. RemoveResponseHeader GatewayFilter Factory
  • -
  • 5.16. RemoveRequestParameter GatewayFilter Factory
  • -
  • 5.17. RewritePath GatewayFilter Factory
  • -
  • 5.18. RewriteLocationResponseHeader GatewayFilter Factory
  • -
  • 5.19. RewriteResponseHeader GatewayFilter Factory
  • -
  • 5.20. SaveSession GatewayFilter Factory
  • -
  • 5.21. SecureHeaders GatewayFilter Factory
  • -
  • 5.22. SetPath GatewayFilter Factory
  • -
  • 5.23. SetRequestHeader GatewayFilter Factory
  • -
  • 5.24. SetResponseHeader GatewayFilter Factory
  • -
  • 5.25. SetStatus GatewayFilter Factory
  • -
  • 5.26. StripPrefix GatewayFilter Factory
  • -
  • 5.27. Retry GatewayFilter Factory
  • -
  • 5.28. RequestSize GatewayFilter Factory
  • -
  • 5.29. Modify Request Body GatewayFilter Factory
  • -
  • 5.30. Modify Response Body GatewayFilter Factory
  • -
  • 5.31. Default Filters
  • +
  • 5.11. RedirectTo GatewayFilter Factory
  • +
  • 5.12. RemoveHopByHopHeadersFilter GatewayFilter Factory
  • +
  • 5.13. RemoveRequestHeader GatewayFilter Factory
  • +
  • 5.14. RemoveResponseHeader GatewayFilter Factory
  • +
  • 5.15. RemoveRequestParameter GatewayFilter Factory
  • +
  • 5.16. RewritePath GatewayFilter Factory
  • +
  • 5.17. RewriteLocationResponseHeader GatewayFilter Factory
  • +
  • 5.18. RewriteResponseHeader GatewayFilter Factory
  • +
  • 5.19. SaveSession GatewayFilter Factory
  • +
  • 5.20. SecureHeaders GatewayFilter Factory
  • +
  • 5.21. SetPath GatewayFilter Factory
  • +
  • 5.22. SetRequestHeader GatewayFilter Factory
  • +
  • 5.23. SetResponseHeader GatewayFilter Factory
  • +
  • 5.24. SetStatus GatewayFilter Factory
  • +
  • 5.25. StripPrefix GatewayFilter Factory
  • +
  • 5.26. Retry GatewayFilter Factory
  • +
  • 5.27. RequestSize GatewayFilter Factory
  • +
  • 5.28. Modify Request Body GatewayFilter Factory
  • +
  • 5.29. Modify Response Body GatewayFilter Factory
  • +
  • 5.30. Default Filters
  • 6. Global Filters @@ -851,19 +850,6 @@ If two hops of trusted infrastructure are required before Spring Cloud Gateway i

    5.5. Hystrix GatewayFilter Factory

    -
    - - - - - -
    - - -Netflix has put Hystrix in maintenance mode. It is suggested you use the Spring Cloud CircuitBreaker -Gateway Filter with Resilience4J as support for Hystrix will be removed in a future release. -
    -

    Hystrix is a library from Netflix that implements the circuit breaker pattern. The Hystrix GatewayFilter allows you to introduce circuit breakers to your gateway routes, protecting your services from cascading failures and allowing you to provide fallback responses in the event of downstream failures.

    @@ -969,125 +955,9 @@ on it in the FallbackHeaders GatewayFilter Factory
    -

    5.6. Spring Cloud CircuitBreaker GatewayFilter Factory

    +

    5.6. FallbackHeaders GatewayFilter Factory

    -

    The Spring Cloud CircuitBreaker filter factory leverages the Spring Cloud CircuitBreaker APIs to wrap Gateway routes in -a circuit breaker. Spring Cloud CircuitBreaker supports two libraries which can be used with Spring Cloud Gateway, Hystrix -and Resilience4J. Since Netflix has places Hystrix in maintenance only mode we suggest you use Resilience4J.

    -
    -
    -

    To enable the Spring Cloud CircuitBreaker filter you will need to either place spring-cloud-starter-circuitbreaker-reactor-resilience4j or -spring-cloud-starter-netflix-hystrix on the classpath.

    -
    -
    -
    application.yml
    -
    -
    spring:
    -  cloud:
    -    gateway:
    -      routes:
    -      - id: circuitbreaker_route
    -        uri: https://example.org
    -        filters:
    -        - CircuitBreaker=myCircuitBreaker
    -
    -
    -
    -

    To configure the circuit breaker, see the configuration for the underlying circuit breaker implementation you are using.

    -
    - -
    -

    The Spring Cloud CircuitBreaker filter can also accept an optional fallbackUri parameter. Currently, only forward: schemed URIs are supported. If the fallback is called, the request will be forwarded to the controller matched by the URI.

    -
    -
    -
    application.yml
    -
    -
    spring:
    -  cloud:
    -    gateway:
    -      routes:
    -      - id: circuitbreaker_route
    -        uri: lb://backing-service:8088
    -        predicates:
    -        - Path=/consumingServiceEndpoint
    -        filters:
    -        - name: CircuitBreaker
    -          args:
    -            name: myCircuitBreaker
    -            fallbackUri: forward:/inCaseOfFailureUseThis
    -        - RewritePath=/consumingServiceEndpoint, /backingServiceEndpoint
    -
    -
    -
    -
    Application.java
    -
    -
    @Bean
    -public RouteLocator routes(RouteLocatorBuilder builder) {
    -    return builder.routes()
    -        .route("circuitbreaker_route", r -> r.path("/consumingServiceEndpoint")
    -            .filters(f -> f.circuitBreaker(c -> c.name("myCircuitBreaker").fallbackUri("forward:/inCaseOfFailureUseThis"))
    -                .rewritePath("/consumingServiceEndpoint", "/backingServiceEndpoint")).uri("lb://backing-service:8088")
    -        .build();
    -}
    -
    -
    -
    -

    This will forward to the /inCaseofFailureUseThis URI when the circuit breaker fallback is called. Note that this example also demonstrates (optional) Spring Cloud Netflix Ribbon load-balancing via the lb prefix on the destination URI.

    -
    -
    -

    The primary scenario is to use the fallbackUri to an internal controller or handler within the gateway app. -However, it is also possible to reroute the request to a controller or handler in an external application, like so:

    -
    -
    -
    application.yml
    -
    -
    spring:
    -  cloud:
    -    gateway:
    -      routes:
    -      - id: ingredients
    -        uri: lb://ingredients
    -        predicates:
    -        - Path=//ingredients/**
    -        filters:
    -        - name: CircuitBreaker
    -          args:
    -            name: fetchIngredients
    -            fallbackUri: forward:/fallback
    -      - id: ingredients-fallback
    -        uri: http://localhost:9994
    -        predicates:
    -        - Path=/fallback
    -
    -
    -
    -

    In this example, there is no fallback endpoint or handler in the gateway application, however, there is one in another -app, registered under localhost:9994.

    -
    -
    -

    In case of the request being forwarded to fallback, the Spring Cloud CircuitBreaker Gateway filter also provides the Throwable that has -caused it. It’s added to the ServerWebExchange as the -ServerWebExchangeUtils.CIRCUITBREAKER_EXECUTION_EXCEPTION_ATTR attribute that can be used when -handling the fallback within the gateway app.

    -
    -
    -

    For the external controller/handler scenario, headers can be added with exception details. You can find more information -on it in the FallbackHeaders GatewayFilter Factory section.

    -
    -
    -
    -

    5.7. FallbackHeaders GatewayFilter Factory

    -
    -

    The FallbackHeaders factory allows you to add Hystrix or Spring Cloud CircuitBreaker execution exception details in headers of a request forwarded to +

    The FallbackHeaders factory allows you to add Hystrix execution exception details in headers of a request forwarded to a fallbackUri in an external application, like in the following scenario:

    @@ -1102,7 +972,7 @@ a fallbackUri in an external application, like in the following sce predicates: - Path=//ingredients/** filters: - - name: CircuitBreaker + - name: Hystrix args: name: fetchIngredients fallbackUri: forward:/fallback @@ -1117,7 +987,7 @@ a fallbackUri in an external application, like in the following sce
    -

    In this example, after an execution exception occurs while running the circuit breaker, the request will be forwarded to +

    In this example, after an execution exception occurs while running the HystrixCommand, the request will be forwarded to the fallback endpoint or handler in an app running on localhost:9994. The headers with the exception type, message and -if available- root cause exception type and message will be added to that request by the FallbackHeaders filter.

    @@ -1142,12 +1012,11 @@ their default values:

    -

    For more information of circuit beakers and the Gateway see the Hystrix GatewayFilter Factory section or -Spring Cloud CircuitBreaker Factory section.

    +

    You can find more information on how Hystrix works with Gateway in the Hystrix GatewayFilter Factory section.

    -

    5.8. MapRequestHeader GatewayFilter Factory

    +

    5.7. MapRequestHeader GatewayFilter Factory

    The MapRequestHeader GatewayFilter Factory takes 'fromHeader' and 'toHeader' parameters. It creates a new named header (toHeader) and the value is extracted out of an existing named header (fromHeader) from the incoming http request. If the input header does not exist then the filter has no impact. If the new named header already exists then it’s values will be augmented with the new values.

    @@ -1169,7 +1038,7 @@ their default values:

    -

    5.9. PrefixPath GatewayFilter Factory

    +

    5.8. PrefixPath GatewayFilter Factory

    The PrefixPath GatewayFilter Factory takes a single prefix parameter.

    @@ -1191,7 +1060,7 @@ their default values:

    -

    5.10. PreserveHostHeader GatewayFilter Factory

    +

    5.9. PreserveHostHeader GatewayFilter Factory

    The PreserveHostHeader GatewayFilter Factory has no parameters. This filter sets a request attribute that the routing filter will inspect to determine if the original host header should be sent, rather than the host header determined by the http client.

    @@ -1210,7 +1079,7 @@ their default values:

    -

    5.11. RequestRateLimiter GatewayFilter Factory

    +

    5.10. RequestRateLimiter GatewayFilter Factory

    The RequestRateLimiter GatewayFilter Factory is uses a RateLimiter implementation to determine if the current request is allowed to proceed. If it is not, a status of HTTP 429 - Too Many Requests (by default) is returned.

    @@ -1257,7 +1126,7 @@ spring.cloud.gateway.routes[0].filters[0]=RequestRateLimiter=2, 2, #{@userkeyres
    -

    5.11.1. Redis RateLimiter

    +

    5.10.1. Redis RateLimiter

    The redis implementation is based off of work done at Stripe. It requires the use of the spring-boot-starter-data-redis-reactive Spring Boot starter.

    @@ -1323,7 +1192,7 @@ KeyResolver userKeyResolver() {
    -

    5.12. RedirectTo GatewayFilter Factory

    +

    5.11. RedirectTo GatewayFilter Factory

    The RedirectTo GatewayFilter Factory takes a status and a url parameter. The status should be a 300 series redirect http code, such as 301. The url should be a valid url. This will be the value of the Location header.

    @@ -1345,7 +1214,7 @@ KeyResolver userKeyResolver() {
    -

    5.13. RemoveHopByHopHeadersFilter GatewayFilter Factory

    +

    5.12. RemoveHopByHopHeadersFilter GatewayFilter Factory

    The RemoveHopByHopHeadersFilter GatewayFilter Factory removes headers from forwarded requests. The default list of headers that is removed comes from the IETF.

    @@ -1383,7 +1252,7 @@ KeyResolver userKeyResolver() {
    -

    5.14. RemoveRequestHeader GatewayFilter Factory

    +

    5.13. RemoveRequestHeader GatewayFilter Factory

    The RemoveRequestHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.

    @@ -1405,7 +1274,7 @@ KeyResolver userKeyResolver() {
    -

    5.15. RemoveResponseHeader GatewayFilter Factory

    +

    5.14. RemoveResponseHeader GatewayFilter Factory

    The RemoveResponseHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.

    @@ -1432,7 +1301,7 @@ and have it applied to all routes.

    -

    5.16. RemoveRequestParameter GatewayFilter Factory

    +

    5.15. RemoveRequestParameter GatewayFilter Factory

    The RemoveRequestParameter GatewayFilter Factory takes a name parameter. It is the name of the query parameter to be removed.

    @@ -1454,7 +1323,7 @@ and have it applied to all routes.

    -

    5.17. RewritePath GatewayFilter Factory

    +

    5.16. RewritePath GatewayFilter Factory

    The RewritePath GatewayFilter Factory takes a path regexp parameter and a replacement parameter. This uses Java regular expressions for a flexible way to rewrite the request path.

    @@ -1478,7 +1347,7 @@ and have it applied to all routes.

    -

    5.18. RewriteLocationResponseHeader GatewayFilter Factory

    +

    5.17. RewriteLocationResponseHeader GatewayFilter Factory

    The RewriteLocationResponseHeader GatewayFilter Factory modifies the value of Location response header, usually to get rid of backend specific details. It takes stripVersionMode, locationHeaderName, hostValue, and protocolsRegex parameters.

    @@ -1522,7 +1391,7 @@ and have it applied to all routes.

    -

    5.19. RewriteResponseHeader GatewayFilter Factory

    +

    5.18. RewriteResponseHeader GatewayFilter Factory

    The RewriteResponseHeader GatewayFilter Factory takes name, regexp, and replacement parameters. It uses Java regular expressions for a flexible way to rewrite the response header value.

    @@ -1544,7 +1413,7 @@ and have it applied to all routes.

    -

    5.20. SaveSession GatewayFilter Factory

    +

    5.19. SaveSession GatewayFilter Factory

    The SaveSession GatewayFilter Factory forces a WebSession::save operation before forwarding the call downstream. This is of particular use when using something like Spring Session with a lazy data store and need to ensure the session state has been saved before making the forwarded call.

    @@ -1569,7 +1438,7 @@ using something like Spring
    -

    5.21. SecureHeaders GatewayFilter Factory

    +

    5.20. SecureHeaders GatewayFilter Factory

    The SecureHeaders GatewayFilter Factory adds a number of headers to the response at the recommendation from this blog post.

    @@ -1643,7 +1512,7 @@ using something like Spring
    -

    5.22. SetPath GatewayFilter Factory

    +

    5.21. SetPath GatewayFilter Factory

    The SetPath GatewayFilter Factory takes a path template parameter. It offers a simple way to manipulate the request path by allowing templated segments of the path. This uses the uri templates from Spring Framework. Multiple matching segments are allowed.

    @@ -1667,7 +1536,7 @@ using something like Spring
    -

    5.23. SetRequestHeader GatewayFilter Factory

    +

    5.22. SetRequestHeader GatewayFilter Factory

    The SetRequestHeader GatewayFilter Factory takes name and value parameters.

    @@ -1707,7 +1576,7 @@ using something like Spring
    -

    5.24. SetResponseHeader GatewayFilter Factory

    +

    5.23. SetResponseHeader GatewayFilter Factory

    The SetResponseHeader GatewayFilter Factory takes name and value parameters.

    @@ -1747,7 +1616,7 @@ using something like Spring
    -

    5.25. SetStatus GatewayFilter Factory

    +

    5.24. SetStatus GatewayFilter Factory

    The SetStatus GatewayFilter Factory takes a single status parameter. It must be a valid Spring HttpStatus. It may be the integer value 404 or the string representation of the enumeration NOT_FOUND.

    @@ -1786,7 +1655,7 @@ using something like Spring
    -

    5.26. StripPrefix GatewayFilter Factory

    +

    5.25. StripPrefix GatewayFilter Factory

    The StripPrefix GatewayFilter Factory takes one parameter, parts. The parts parameter indicated the number of parts in the path to strip from the request before sending it downstream.

    @@ -1810,7 +1679,7 @@ using something like Spring
    -

    5.27. Retry GatewayFilter Factory

    +

    5.26. Retry GatewayFilter Factory

    The Retry GatewayFilter Factory support following set of parameters:

    @@ -1909,7 +1778,7 @@ When using the retry filter with a forward: prefixed URL, the targe
    -

    5.28. RequestSize GatewayFilter Factory

    +

    5.27. RequestSize GatewayFilter Factory

    The RequestSize GatewayFilter Factory can restrict a request from reaching the downstream service , when the request size is greater than the permissible limit. The filter takes RequestSize as parameter which is the permissible size limit of the request defined in bytes.

    @@ -1950,7 +1819,7 @@ The default Request size will be set to 5 MB if not provided as filter argument
    -

    5.29. Modify Request Body GatewayFilter Factory

    +

    5.28. Modify Request Body GatewayFilter Factory

    This filter is considered BETA and the API may change in the future

    @@ -2002,7 +1871,7 @@ static class Hello {
    -

    5.30. Modify Response Body GatewayFilter Factory

    +

    5.29. Modify Response Body GatewayFilter Factory

    This filter is considered BETA and the API may change in the future

    @@ -2036,7 +1905,7 @@ public RouteLocator routes(RouteLocatorBuilder builder) {
    -

    5.31. Default Filters

    +

    5.30. Default Filters

    If you would like to add a filter and apply it to all routes you can use spring.cloud.gateway.default-filters. This property takes a list of filters