spring:
- cloud:
- gateway:
- routes:
- - id: circuitbreaker_route
- uri: https://example.org
- filters:
- - CircuitBreaker=myCircuitBreaker
-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);
| - - | --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 FactoryThe 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.
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.
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
-@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:
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.
-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:
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.
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.
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.
The PrefixPath GatewayFilter Factory takes a single prefix parameter.
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.
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.
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.
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.
The RemoveHopByHopHeadersFilter GatewayFilter Factory removes headers from forwarded requests. The default list of headers that is removed comes from the IETF.
The RemoveRequestHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.
The RemoveResponseHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.
The RemoveRequestParameter GatewayFilter Factory takes a name parameter. It is the name of the query parameter to be removed.
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.
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.
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.
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.
The SecureHeaders GatewayFilter Factory adds a number of headers to the response at the recommendation from this blog post.
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.
The SetRequestHeader GatewayFilter Factory takes name and value parameters.
The SetResponseHeader GatewayFilter Factory takes name and value parameters.
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.
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.
The Retry GatewayFilter Factory support following set of parameters:
forward: prefixed URL, the targe
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.
This filter is considered BETA and the API may change in the future
This filter is considered BETA and the API may change in the future
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
| - - | --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 FactoryThe 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.
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.
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
-@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:
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.
-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:
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.
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.
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.
The PrefixPath GatewayFilter Factory takes a single prefix parameter.
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.
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.
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.
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.
The RemoveHopByHopHeadersFilter GatewayFilter Factory removes headers from forwarded requests. The default list of headers that is removed comes from the IETF.
The RemoveRequestHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.
The RemoveResponseHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.
The RemoveRequestParameter GatewayFilter Factory takes a name parameter. It is the name of the query parameter to be removed.
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.
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.
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.
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.
The SecureHeaders GatewayFilter Factory adds a number of headers to the response at the recommendation from this blog post.
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.
The SetRequestHeader GatewayFilter Factory takes name and value parameters.
The SetResponseHeader GatewayFilter Factory takes name and value parameters.
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.
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.
The Retry GatewayFilter Factory support following set of parameters:
forward: prefixed URL, the targe
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.
This filter is considered BETA and the API may change in the future
This filter is considered BETA and the API may change in the future
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