spring:
- cloud:
- gateway:
- routes:
- - id: hystrix_route
- uri: https://example.org
- filters:
- - Hystrix=myCommandName
-diff --git a/reference/html/index.html b/reference/html/index.html index 8735b211..8f14183e 100644 --- a/reference/html/index.html +++ b/reference/html/index.html @@ -124,37 +124,36 @@ $(addBlockSwitches);
AddRequestParameter GatewayFilter FactoryAddResponseHeader GatewayFilter FactoryDedupeResponseHeader GatewayFilter FactoryGatewayFilter FactoryFallbackHeaders GatewayFilter FactoryMapRequestHeader GatewayFilter FactoryPrefixPath GatewayFilter FactoryPreserveHostHeader GatewayFilter FactoryRequestRateLimiter GatewayFilter Factory
+FallbackHeaders GatewayFilter FactoryMapRequestHeader GatewayFilter FactoryPrefixPath GatewayFilter FactoryPreserveHostHeader GatewayFilter FactoryRequestRateLimiter GatewayFilter Factory
RedirectTo GatewayFilter FactoryRemoveHopByHopHeadersFilter GatewayFilter FactoryRemoveRequestHeader GatewayFilter FactoryRemoveResponseHeader GatewayFilter FactoryRemoveRequestParameter GatewayFilter FactoryRewritePath GatewayFilter FactoryRewriteLocationResponseHeader GatewayFilter FactoryRewriteResponseHeader GatewayFilter FactorySaveSession GatewayFilter FactorySecureHeaders GatewayFilter FactorySetPath GatewayFilter FactorySetRequestHeader GatewayFilter FactorySetResponseHeader GatewayFilter FactorySetStatus GatewayFilter FactoryStripPrefix GatewayFilter FactoryGatewayFilter FactoryRequestSize GatewayFilter FactoryGatewayFilter FactoryGatewayFilter FactoryRedirectTo GatewayFilter FactoryRemoveHopByHopHeadersFilter GatewayFilter FactoryRemoveRequestHeader GatewayFilter FactoryRemoveResponseHeader GatewayFilter FactoryRemoveRequestParameter GatewayFilter FactoryRewritePath GatewayFilter FactoryRewriteLocationResponseHeader GatewayFilter FactoryRewriteResponseHeader GatewayFilter FactorySaveSession GatewayFilter FactorySecureHeaders GatewayFilter FactorySetPath GatewayFilter FactorySetRequestHeader GatewayFilter FactorySetResponseHeader GatewayFilter FactorySetStatus GatewayFilter FactoryStripPrefix GatewayFilter FactoryGatewayFilter FactoryRequestSize GatewayFilter FactoryGatewayFilter FactoryGatewayFilter Factory2.2.2.BUILD-SNAPSHOT
+3.0.0.BUILD-SNAPSHOT
This project provides an API Gateway built on top of the Spring Ecosystem, including: Spring 5, Spring Boot 2 and Project Reactor. Spring Cloud Gateway aims to provide a simple, yet effective way to route to APIs and provide cross cutting concerns to them such as: security, monitoring/metrics, and resiliency.
@@ -997,142 +996,7 @@ The accepted values areRETAIN_FIRST (default), RETAIN_LAST
GatewayFilter Factory| - - | --Netflix has put Hystrix in maintenance mode. We suggest 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 lets you introduce circuit breakers to your gateway routes, protecting your services from cascading failures and letting you provide fallback responses in the event of downstream failures.
To enable Hystrix GatewayFilter instances in your project, add a dependency on spring-cloud-starter-netflix-hystrix from Spring Cloud Netflix.
The Hystrix GatewayFilter factory requires a single name parameter, which is the name of the HystrixCommand.
-The following example configures a Hystrix GatewayFilter:
spring:
- cloud:
- gateway:
- routes:
- - id: hystrix_route
- uri: https://example.org
- filters:
- - Hystrix=myCommandName
-This wraps the remaining filters in a HystrixCommand with a command name of myCommandName.
The Hystrix filter can also accept an optional fallbackUri parameter. Currently, only forward: schemed URIs are supported. If the fallback is called, the request is forwarded to the controller matched by the URI.
-The following example configures such a fallback:
spring:
- cloud:
- gateway:
- routes:
- - id: hystrix_route
- uri: lb://backing-service:8088
- predicates:
- - Path=/consumingserviceendpoint
- filters:
- - name: Hystrix
- args:
- name: fallbackcmd
- fallbackUri: forward:/incaseoffailureusethis
- - RewritePath=/consumingserviceendpoint, /backingserviceendpoint
-This will forward to the /incaseoffailureusethis URI when the Hystrix fallback is called. Note that this example also demonstrates (optional) Spring Cloud Netflix Ribbon load-balancing (defined 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, you can also reroute the request to a controller or handler in an external application, as follows:
spring:
- cloud:
- gateway:
- routes:
- - id: ingredients
- uri: lb://ingredients
- predicates:
- - Path=//ingredients/**
- filters:
- - name: Hystrix
- 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 application, registered under localhost:9994.
In case of the request being forwarded to the fallback, the Hystrix Gateway filter also provides the Throwable that has caused it.
-It is added to the ServerWebExchange as the ServerWebExchangeUtils.HYSTRIX_EXECUTION_EXCEPTION_ATTR attribute, which you can use when handling the fallback within the gateway application.
For the external controller/handler scenario, you can add headers with exception details. -You can find more information on doing so in the FallbackHeaders GatewayFilter Factory section.
-You can configured Hystrix settings (such as timeouts) with global defaults or on a route-by-route basis by using application properties, as explained on the Hystrix wiki.
-To set a five-second timeout for the example route shown earlier, you could use the following configuration:
-hystrix.command.fallbackcmd.execution.isolation.thread.timeoutInMilliseconds: 5000
-The Spring Cloud CircuitBreaker GatewayFilter factory uses the Spring Cloud CircuitBreaker APIs to wrap Gateway routes in
a circuit breaker. Spring Cloud CircuitBreaker supports two libraries that can be used with Spring Cloud Gateway, Hystrix
@@ -1143,7 +1007,7 @@ and Resilience4J. Since Netflix has placed Hystrix in maintenance-only mode, we
The following example configures a Spring Cloud CircuitBreaker GatewayFilter:
The following listing does the same thing in Java:
FallbackHeaders GatewayFilter FactoryFallbackHeaders GatewayFilter FactoryThe FallbackHeaders factory lets you add Hystrix or Spring Cloud CircuitBreaker execution exception details in the headers of a request forwarded to a fallbackUri in an external application, as in the following scenario:
MapRequestHeader GatewayFilter FactoryMapRequestHeader GatewayFilter FactoryThe 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.
@@ -1340,7 +1204,7 @@ If the new named header already exists, its values are augmented with the new va
The following example configures a MapRequestHeader:
MapRequestHeader:
PrefixPath GatewayFilter FactoryPrefixPath GatewayFilter FactoryThe PrefixPath GatewayFilter factory takes a single prefix parameter.
The following example configures a PrefixPath GatewayFilter:
/hello would be sent to /mypath/hello.
PreserveHostHeader GatewayFilter FactoryPreserveHostHeader GatewayFilter FactoryThe PreserveHostHeader GatewayFilter factory has no parameters.
This filter sets a request attribute that the routing filter inspects to determine if the original host header should be sent, rather than the host header determined by the HTTP client.
The following example configures a PreserveHostHeader GatewayFilter:
PreserveHostHeader Gateway
RequestRateLimiter GatewayFilter FactoryRequestRateLimiter GatewayFilter FactoryThe RequestRateLimiter GatewayFilter factory 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.
KeyResolver interface:
spring.cloud.gateway.filter.re
The RequestRateLimiter is not configurable with the "shortcut" notation. The following example below is invalid:
RateLimiterRateLimiterThe 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.
redis-rate-limiter:
redis-rate-limiter:
The following example configures a KeyResolver in Java:
KeyResolver defined in the previous listing:
KeyResolver
RedirectTo GatewayFilter FactoryRedirectTo GatewayFilter FactoryThe RedirectTo GatewayFilter factory takes two parameters, status and url.
The status parameter should be a 300 series redirect HTTP code, such as 301.
@@ -1578,7 +1442,7 @@ For relative redirects, you should use uri: no://op as the uri of y
The following listing configures a RedirectTo GatewayFilter:
RedirectTo GatewayFilter
RemoveHopByHopHeadersFilter GatewayFilter FactoryRemoveHopByHopHeadersFilter GatewayFilter FactoryThe RemoveHopByHopHeadersFilter GatewayFilter Factory removes headers from forwarded requests.
The default list of headers that is removed comes from the IETF.
RemoveRequestHeader GatewayFilter FactoryRemoveRequestHeader GatewayFilter FactoryThe RemoveRequestHeader GatewayFilter factory takes a name parameter.
It is the name of the header to be removed.
The following listing configures a RemoveRequestHeader GatewayFilter:
RemoveRequestHeader Gatewa
RemoveResponseHeader GatewayFilter FactoryRemoveResponseHeader GatewayFilter FactoryThe RemoveResponseHeader GatewayFilter factory takes a name parameter.
It is the name of the header to be removed.
The following listing configures a RemoveResponseHeader GatewayFilter:
spring.cloud.gate
RemoveRequestParameter GatewayFilter FactoryRemoveRequestParameter GatewayFilter FactoryThe RemoveRequestParameter GatewayFilter factory takes a name parameter.
It is the name of the query parameter to be removed.
The following example configures a RemoveRequestParameter GatewayFilter:
RemoveRequestParameter Gat
RewritePath GatewayFilter FactoryRewritePath GatewayFilter FactoryThe 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 following listing configures a RewritePath GatewayFilter:
RewritePath GatewayFilter<
RewriteLocationResponseHeader GatewayFilter FactoryRewriteLocationResponseHeader GatewayFilter FactoryThe RewriteLocationResponseHeader GatewayFilter factory modifies the value of the Location response header, usually to get rid of backend-specific details.
It takes stripVersionMode, locationHeaderName, hostValue, and protocolsRegex parameters.
The following listing configures a RewriteLocationResponseHeader GatewayFilter:
http|https|ftp|ftps.
RewriteResponseHeader GatewayFilter FactoryRewriteResponseHeader GatewayFilter FactoryThe 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 following example configures a RewriteResponseHeader GatewayFilter:
$\ to mean $ because of the YAML specific
SaveSession GatewayFilter FactorySaveSession GatewayFilter FactoryThe 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 you need to ensure the session state has been saved before making the forwarded call.
The following example configures a SaveSession GatewayFilter:
SaveSession GatewayFilter<
SecureHeaders GatewayFilter FactorySecureHeaders GatewayFilter FactoryThe SecureHeaders GatewayFilter factory adds a number of headers to the response, per the recommendation made in this blog post.
SetPath GatewayFilter FactorySetPath GatewayFilter FactoryThe 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.
@@ -1971,7 +1835,7 @@ Multiple matching segments are allowed.
The following example configures a SetPath GatewayFilter:
SetPath GatewayFilter
SetRequestHeader GatewayFilter FactorySetRequestHeader GatewayFilter FactoryThe SetRequestHeader GatewayFilter factory takes name and value parameters.
The following listing configures a SetRequestHeader GatewayFilter:
SetRequestHeader GatewayFilter that uses a variable:
SetRequestHeader GatewayF
SetResponseHeader GatewayFilter FactorySetResponseHeader GatewayFilter FactoryThe SetResponseHeader GatewayFilter factory takes name and value parameters.
The following listing configures a SetResponseHeader GatewayFilter:
SetResponseHeader GatewayFilter that uses a variable:
SetResponseHeader Gateway
SetStatus GatewayFilter FactorySetStatus GatewayFilter FactoryThe SetStatus GatewayFilter factory takes a single parameter, status.
It must be a valid Spring HttpStatus.
@@ -2106,7 +1970,7 @@ It may be the integer value 404 or the string representation of the
The following listing configures a SetStatus GatewayFilter:
SetStatus GatewayFilter
StripPrefix GatewayFilter FactoryStripPrefix GatewayFilter FactoryThe StripPrefix GatewayFilter factory takes one parameter, parts.
The parts parameter indicates the number of parts in the path to strip from the request before sending it downstream.
The following listing configures a StripPrefix GatewayFilter:
StripPrefix GatewayFilter<
GatewayFilter FactoryGatewayFilter FactoryThe Retry GatewayFilter factory supports the following parameters:
basedOnPreviousValue is true, the backoff is calculated byusing
The following listing configures a Retry GatewayFilter:
Exception or signal an error (for examp
RequestSize GatewayFilter FactoryRequestSize GatewayFilter FactoryWhen the request size is greater than the permissible limit, the RequestSize GatewayFilter factory can restrict a request from reaching the downstream service.
The filter takes a RequestSize parameter.
@@ -2296,7 +2160,7 @@ It is the permissible size limit of the request defined in bytes.
The following listing configures a RequestSize GatewayFilter:
GatewayFilter FactoryGatewayFilter Factory