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);
  • 5.2. The AddRequestParameter GatewayFilter Factory
  • 5.3. The AddResponseHeader GatewayFilter Factory
  • 5.4. The DedupeResponseHeader GatewayFilter Factory
  • -
  • 5.5. The Hystrix GatewayFilter Factory
  • -
  • 5.6. Spring Cloud CircuitBreaker GatewayFilter Factory
  • -
  • 5.7. The FallbackHeaders GatewayFilter Factory
  • -
  • 5.8. The MapRequestHeader GatewayFilter Factory
  • -
  • 5.9. The PrefixPath GatewayFilter Factory
  • -
  • 5.10. The PreserveHostHeader GatewayFilter Factory
  • -
  • 5.11. The RequestRateLimiter GatewayFilter Factory +
  • 5.5. Spring Cloud CircuitBreaker GatewayFilter Factory
  • +
  • 5.6. The FallbackHeaders GatewayFilter Factory
  • +
  • 5.7. The MapRequestHeader GatewayFilter Factory
  • +
  • 5.8. The PrefixPath GatewayFilter Factory
  • +
  • 5.9. The PreserveHostHeader GatewayFilter Factory
  • +
  • 5.10. The RequestRateLimiter GatewayFilter Factory
  • -
  • 5.12. The RedirectTo GatewayFilter Factory
  • -
  • 5.13. The RemoveHopByHopHeadersFilter GatewayFilter Factory
  • -
  • 5.14. The RemoveRequestHeader GatewayFilter Factory
  • -
  • 5.15. RemoveResponseHeader GatewayFilter Factory
  • -
  • 5.16. The RemoveRequestParameter GatewayFilter Factory
  • -
  • 5.17. The RewritePath GatewayFilter Factory
  • -
  • 5.18. RewriteLocationResponseHeader GatewayFilter Factory
  • -
  • 5.19. The RewriteResponseHeader GatewayFilter Factory
  • -
  • 5.20. The SaveSession GatewayFilter Factory
  • -
  • 5.21. The SecureHeaders GatewayFilter Factory
  • -
  • 5.22. The SetPath GatewayFilter Factory
  • -
  • 5.23. The SetRequestHeader GatewayFilter Factory
  • -
  • 5.24. The SetResponseHeader GatewayFilter Factory
  • -
  • 5.25. The SetStatus GatewayFilter Factory
  • -
  • 5.26. The StripPrefix GatewayFilter Factory
  • -
  • 5.27. The Retry GatewayFilter Factory
  • -
  • 5.28. The RequestSize GatewayFilter Factory
  • -
  • 5.29. Modify a Request Body GatewayFilter Factory
  • -
  • 5.30. Modify a Response Body GatewayFilter Factory
  • -
  • 5.31. Default Filters
  • +
  • 5.11. The RedirectTo GatewayFilter Factory
  • +
  • 5.12. The RemoveHopByHopHeadersFilter GatewayFilter Factory
  • +
  • 5.13. The RemoveRequestHeader GatewayFilter Factory
  • +
  • 5.14. RemoveResponseHeader GatewayFilter Factory
  • +
  • 5.15. The RemoveRequestParameter GatewayFilter Factory
  • +
  • 5.16. The RewritePath GatewayFilter Factory
  • +
  • 5.17. RewriteLocationResponseHeader GatewayFilter Factory
  • +
  • 5.18. The RewriteResponseHeader GatewayFilter Factory
  • +
  • 5.19. The SaveSession GatewayFilter Factory
  • +
  • 5.20. The SecureHeaders GatewayFilter Factory
  • +
  • 5.21. The SetPath GatewayFilter Factory
  • +
  • 5.22. The SetRequestHeader GatewayFilter Factory
  • +
  • 5.23. The SetResponseHeader GatewayFilter Factory
  • +
  • 5.24. The SetStatus GatewayFilter Factory
  • +
  • 5.25. The StripPrefix GatewayFilter Factory
  • +
  • 5.26. The Retry GatewayFilter Factory
  • +
  • 5.27. The RequestSize GatewayFilter Factory
  • +
  • 5.28. Modify a Request Body GatewayFilter Factory
  • +
  • 5.29. Modify a Response Body GatewayFilter Factory
  • +
  • 5.30. Default Filters
  • 6. Global Filters @@ -231,7 +230,7 @@ $(addBlockSwitches);
    -

    2.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 are RETAIN_FIRST (default), RETAIN_LAST
    -

    5.5. The Hystrix 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:

    -
    -
    -
    Example 20. application.yml
    -
    -
    -
    -
    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:

    -
    -
    -
    Example 21. application.yml
    -
    -
    -
    -
    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:

    -
    -
    -
    Example 22. application.yml
    -
    -
    -
    -
    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:

    -
    -
    -
    Example 23. application.yml
    -
    -
    -
    -
    hystrix.command.fallbackcmd.execution.isolation.thread.timeoutInMilliseconds: 5000
    -
    -
    -
    -
    -
    -
    -

    5.6. Spring Cloud CircuitBreaker GatewayFilter Factory

    +

    5.5. Spring Cloud CircuitBreaker GatewayFilter Factory

    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:

    -
    Example 24. application.yml
    +
    Example 20. application.yml
    @@ -1179,7 +1043,7 @@ If the fallback is called, the request is forwarded to the controller matched by The following example configures such a fallback:

    -
    Example 25. application.yml
    +
    Example 21. application.yml
    @@ -1205,7 +1069,7 @@ The following example configures such a fallback:

    The following listing does the same thing in Java:

    -
    Example 26. Application.java
    +
    Example 22. Application.java
    @@ -1230,7 +1094,7 @@ Note that this example also demonstrates the (optional) Spring Cloud Netflix Rib However, you can also reroute the request to a controller or handler in an external application, as follows:

    -
    Example 27. application.yml
    +
    Example 23. application.yml
    @@ -1269,12 +1133,12 @@ You can find more information on doing so in the Fa
    -

    5.7. The FallbackHeaders GatewayFilter Factory

    +

    5.6. The FallbackHeaders GatewayFilter Factory

    The 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:

    -
    Example 28. application.yml
    +
    Example 24. application.yml
    @@ -1331,7 +1195,7 @@ The headers with the exception type, message and (if available) root cause excep
    -

    5.8. The MapRequestHeader GatewayFilter Factory

    +

    5.7. The 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. @@ -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:

    -
    Example 29. application.yml
    +
    Example 25. application.yml
    @@ -1361,13 +1225,13 @@ The following example configures a MapRequestHeader:

    -

    5.9. The PrefixPath GatewayFilter Factory

    +

    5.8. The PrefixPath GatewayFilter Factory

    The PrefixPath GatewayFilter factory takes a single prefix parameter. The following example configures a PrefixPath GatewayFilter:

    -
    Example 30. application.yml
    +
    Example 26. application.yml
    @@ -1389,14 +1253,14 @@ So a request to /hello would be sent to /mypath/hello.
    -

    5.10. The PreserveHostHeader GatewayFilter Factory

    +

    5.9. The PreserveHostHeader GatewayFilter Factory

    The 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:

    -
    Example 31. application.yml
    +
    Example 27. application.yml
    @@ -1414,7 +1278,7 @@ The following example configures a PreserveHostHeader Gateway
    -

    5.11. The RequestRateLimiter GatewayFilter Factory

    +

    5.10. The RequestRateLimiter GatewayFilter Factory

    The 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.

    @@ -1428,7 +1292,7 @@ In configuration, reference the bean by name using SpEL. The following listing shows the KeyResolver interface:

    -
    Example 32. KeyResolver.java
    +
    Example 28. KeyResolver.java
    @@ -1461,7 +1325,7 @@ You can adjust this behavior by setting the spring.cloud.gateway.filter.re

    The RequestRateLimiter is not configurable with the "shortcut" notation. The following example below is invalid:

    -
    Example 33. application.properties
    +
    Example 29. application.properties
    @@ -1476,7 +1340,7 @@ spring.cloud.gateway.routes[0].filters[0]=RequestRateLimiter=2, 2, #{@userkeyres
    -

    5.11.1. The Redis RateLimiter

    +

    5.10.1. The 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.

    @@ -1500,7 +1364,7 @@ In this case, the rate limiter needs to be allowed some time between bursts (acc The following listing configures a redis-rate-limiter:

    -
    Example 34. application.yml
    +
    Example 30. application.yml
    @@ -1523,7 +1387,7 @@ The following listing configures a redis-rate-limiter:

    The following example configures a KeyResolver in Java:

    -
    Example 35. Config.java
    +
    Example 31. Config.java
    @@ -1546,7 +1410,7 @@ In configuration, you can reference the bean by name using SpEL. The following listing defines a rate limiter that uses the KeyResolver defined in the previous listing:

    -
    Example 36. application.yml
    +
    Example 32. application.yml
    @@ -1568,7 +1432,7 @@ The following listing defines a rate limiter that uses the KeyResolver
    -

    5.12. The RedirectTo GatewayFilter Factory

    +

    5.11. The RedirectTo GatewayFilter Factory

    The 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:

    -
    Example 37. application.yml
    +
    Example 33. application.yml
    @@ -1599,7 +1463,7 @@ The following listing configures a RedirectTo GatewayFilter
    -

    5.13. The RemoveHopByHopHeadersFilter GatewayFilter Factory

    +

    5.12. The RemoveHopByHopHeadersFilter GatewayFilter Factory

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

    @@ -1638,14 +1502,14 @@ The default list of headers that is removed comes from the -

    5.14. The RemoveRequestHeader GatewayFilter Factory

    +

    5.13. The RemoveRequestHeader GatewayFilter Factory

    The RemoveRequestHeader GatewayFilter factory takes a name parameter. It is the name of the header to be removed. The following listing configures a RemoveRequestHeader GatewayFilter:

    -
    Example 38. application.yml
    +
    Example 34. application.yml
    @@ -1666,14 +1530,14 @@ The following listing configures a RemoveRequestHeader Gatewa
    -

    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. The following listing configures a RemoveResponseHeader GatewayFilter:

    -
    Example 39. application.yml
    +
    Example 35. application.yml
    @@ -1698,14 +1562,14 @@ In addition, you can configure this filter once by using spring.cloud.gate
    -

    5.16. The RemoveRequestParameter GatewayFilter Factory

    +

    5.15. The RemoveRequestParameter GatewayFilter Factory

    The 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:

    -
    Example 40. application.yml
    +
    Example 36. application.yml
    @@ -1726,14 +1590,14 @@ The following example configures a RemoveRequestParameter Gat
    -

    5.17. The RewritePath GatewayFilter Factory

    +

    5.16. The 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. The following listing configures a RewritePath GatewayFilter:

    -
    Example 41. application.yml
    +
    Example 37. application.yml
    @@ -1756,14 +1620,14 @@ The following listing configures a RewritePath GatewayFilter<
    -

    5.18. RewriteLocationResponseHeader GatewayFilter Factory

    +

    5.17. RewriteLocationResponseHeader GatewayFilter Factory

    The 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:

    -
    Example 42. application.yml
    +
    Example 38. application.yml
    @@ -1809,14 +1673,14 @@ The default is http|https|ftp|ftps.

    -

    5.19. The RewriteResponseHeader GatewayFilter Factory

    +

    5.18. The 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. The following example configures a RewriteResponseHeader GatewayFilter:

    -
    Example 43. application.yml
    +
    Example 39. application.yml
    @@ -1838,14 +1702,14 @@ You must use $\ to mean $ because of the YAML specific
    -

    5.20. The SaveSession GatewayFilter Factory

    +

    5.19. The 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 you need to ensure the session state has been saved before making the forwarded call. The following example configures a SaveSession GatewayFilter:

    -
    Example 44. application.yml
    +
    Example 40. application.yml
    @@ -1868,7 +1732,7 @@ The following example configures a SaveSession GatewayFilter<
    -

    5.21. The SecureHeaders GatewayFilter Factory

    +

    5.20. The SecureHeaders GatewayFilter Factory

    The SecureHeaders GatewayFilter factory adds a number of headers to the response, per the recommendation made in this blog post.

    @@ -1962,7 +1826,7 @@ The lowercase full name of the secure header needs to be used to disable it..
    -

    5.22. The SetPath GatewayFilter Factory

    +

    5.21. The 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. @@ -1971,7 +1835,7 @@ Multiple matching segments are allowed. The following example configures a SetPath GatewayFilter:

    -
    Example 45. application.yml
    +
    Example 41. application.yml
    @@ -1994,13 +1858,13 @@ The following example configures a SetPath GatewayFilter
    -

    5.23. The SetRequestHeader GatewayFilter Factory

    +

    5.22. The SetRequestHeader GatewayFilter Factory

    The SetRequestHeader GatewayFilter factory takes name and value parameters. The following listing configures a SetRequestHeader GatewayFilter:

    -
    Example 46. application.yml
    +
    Example 42. application.yml
    @@ -2026,7 +1890,7 @@ URI variables may be used in the value and are expanded at runtime. The following example configures an SetRequestHeader GatewayFilter that uses a variable:

    -
    Example 47. application.yml
    +
    Example 43. application.yml
    @@ -2046,13 +1910,13 @@ The following example configures an SetRequestHeader GatewayF
    -

    5.24. The SetResponseHeader GatewayFilter Factory

    +

    5.23. The SetResponseHeader GatewayFilter Factory

    The SetResponseHeader GatewayFilter factory takes name and value parameters. The following listing configures a SetResponseHeader GatewayFilter:

    -
    Example 48. application.yml
    +
    Example 44. application.yml
    @@ -2078,7 +1942,7 @@ URI variables may be used in the value and will be expanded at runtime. The following example configures an SetResponseHeader GatewayFilter that uses a variable:

    -
    Example 49. application.yml
    +
    Example 45. application.yml
    @@ -2098,7 +1962,7 @@ The following example configures an SetResponseHeader Gateway
    -

    5.25. The SetStatus GatewayFilter Factory

    +

    5.24. The SetStatus GatewayFilter Factory

    The 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:

    -
    Example 50. application.yml
    +
    Example 46. application.yml
    @@ -2134,7 +1998,7 @@ The following listing configures a SetStatus GatewayFilter
    -
    Example 51. application.yml
    +
    Example 47. application.yml
    @@ -2149,14 +2013,14 @@ The header is added to the response if configured with the following property:
    -

    5.26. The StripPrefix GatewayFilter Factory

    +

    5.25. The StripPrefix GatewayFilter Factory

    The 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:

    -
    Example 52. application.yml
    +
    Example 48. application.yml
    @@ -2179,7 +2043,7 @@ The following listing configures a StripPrefix GatewayFilter<
    -

    5.27. The Retry GatewayFilter Factory

    +

    5.26. The Retry GatewayFilter Factory

    The Retry GatewayFilter factory supports the following parameters:

    @@ -2234,7 +2098,7 @@ If basedOnPreviousValue is true, the backoff is calculated byusing

    The following listing configures a Retry GatewayFilter:

    -
    Example 53. application.yml
    +
    Example 49. application.yml
    @@ -2288,7 +2152,7 @@ Instead, it should throw an Exception or signal an error (for examp
    -

    5.28. The RequestSize GatewayFilter Factory

    +

    5.27. The RequestSize GatewayFilter Factory

    When 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:

    -
    Example 54. application.yml
    +
    Example 50. application.yml
    @@ -2342,7 +2206,7 @@ The default request size is set to five MB if not provided as a filter argument
    -

    5.29. Modify a Request Body GatewayFilter Factory

    +

    5.28. Modify a Request Body GatewayFilter Factory

    @@ -2410,7 +2274,7 @@ static class Hello {
    @@ -2460,14 +2324,14 @@ public RouteLocator routes(RouteLocatorBuilder builder) {
    -

    5.31. Default Filters

    +

    5.30. Default Filters

    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. The following listing defines a set of default filters:

    -
    Example 55. application.yml
    +
    Example 51. application.yml
    @@ -2516,7 +2380,7 @@ This combined filter chain is sorted by the org.springframework.core.Order

    The following listing configures a filter chain:

    -
    Example 56. ExampleConfiguration.java
    +
    Example 52. ExampleConfiguration.java
    @@ -2563,7 +2427,7 @@ If so, the same rules apply. The following listing configures a LoadBalancerClientFilter:

    -
    Example 57. application.yml
    +
    Example 53. application.yml
    @@ -2638,7 +2502,7 @@ If so, the same rules apply. The following listing configures a ReactiveLoadBalancerClientFilter:

    -
    Example 58. application.yml
    +
    Example 54. application.yml
    @@ -2736,7 +2600,7 @@ If you use SockJS as a fallback over nor

    The following listing configures a websocket routing filter:

    -
    Example 59. application.yml
    +
    Example 55. application.yml
    @@ -2831,7 +2695,7 @@ or check if an exchange has already been routed.

    The following example shows how to do so:

    -
    Example 60. application.yml
    +
    Example 56. application.yml
    @@ -2851,7 +2715,7 @@ The following example shows how to do so:

    If you are routing to an HTTPS backend, you can configure the gateway to trust all downstream certificates with the following configuration:

    -
    Example 61. application.yml
    +
    Example 57. application.yml
    @@ -2870,7 +2734,7 @@ If you are routing to an HTTPS backend, you can configure the gateway to trust a For a production deployment, you can configure the gateway with a set of known certificates that it can trust with the following configuration:

    -
    Example 62. application.yml
    +
    Example 58. application.yml
    @@ -2898,7 +2762,7 @@ A number of timeouts are associated with this handshake. You can configure these timeouts can be configured (defaults shown) as follows:

    -
    Example 63. application.yml
    +
    Example 59. application.yml
    @@ -2925,7 +2789,7 @@ You can configure these timeouts can be configured (defaults shown) as follows:< The following listing shows the definition of the RouteDefinitionLocator interface:

    -
    Example 64. RouteDefinitionLocator.java
    +
    Example 60. RouteDefinitionLocator.java
    @@ -2944,7 +2808,7 @@ The following listing shows the definition of the RouteDefinitionLocator
    -
    Example 65. application.yml
    +
    Example 61. application.yml
    @@ -2978,7 +2842,7 @@ The following two examples are equivalent:

    You can configure additional parameters for each route by using metadata, as follows:

    -
    Example 66. application.yml
    +
    Example 62. application.yml
    @@ -3089,7 +2953,7 @@ import static org.springframework.cloud.gateway.support.RouteMetadataUtils.RESPO The following listing shows how it works:

    -
    Example 67. GatewaySampleApplication.java
    +
    Example 63. GatewaySampleApplication.java
    @@ -3156,7 +3020,7 @@ When doing so, you need to make sure to include the default predicate and filter The following example shows what this looks like:

    -
    Example 68. application.properties
    +
    Example 64. application.properties
    @@ -3199,7 +3063,7 @@ It must be a Java System Property, not a Spring Boot property.

    You can configure the logging system to have a separate access log file. The following example creates a Logback configuration:

    -
    Example 69. logback.xml
    +
    Example 65. logback.xml
    @@ -3230,7 +3094,7 @@ It must be a Java System Property, not a Spring Boot property. The following example configures CORS:

    -
    Example 70. application.yml
    +
    Example 66. application.yml
    @@ -3265,7 +3129,7 @@ To be remotely accessible, the endpoint has to be -
    Example 71. application.properties
    +
    Example 67. application.properties
    @@ -3307,7 +3171,7 @@ The following example configures /actuator/gateway/routes:

    This feature is enabled by default. To disable it, set the following property:

    -
    Example 72. application.properties
    +
    Example 68. application.properties
    @@ -3670,7 +3534,7 @@ You can extend an abstract class called AbstractGatewayFilterFactory
    -
    Example 73. PreGatewayFilterFactory.java
    +
    Example 69. PreGatewayFilterFactory.java
    diff --git a/reference/html/spring-cloud-gateway.html b/reference/html/spring-cloud-gateway.html index 8735b211..8f14183e 100644 --- a/reference/html/spring-cloud-gateway.html +++ b/reference/html/spring-cloud-gateway.html @@ -124,37 +124,36 @@ $(addBlockSwitches);
  • 5.2. The AddRequestParameter GatewayFilter Factory
  • 5.3. The AddResponseHeader GatewayFilter Factory
  • 5.4. The DedupeResponseHeader GatewayFilter Factory
  • -
  • 5.5. The Hystrix GatewayFilter Factory
  • -
  • 5.6. Spring Cloud CircuitBreaker GatewayFilter Factory
  • -
  • 5.7. The FallbackHeaders GatewayFilter Factory
  • -
  • 5.8. The MapRequestHeader GatewayFilter Factory
  • -
  • 5.9. The PrefixPath GatewayFilter Factory
  • -
  • 5.10. The PreserveHostHeader GatewayFilter Factory
  • -
  • 5.11. The RequestRateLimiter GatewayFilter Factory +
  • 5.5. Spring Cloud CircuitBreaker GatewayFilter Factory
  • +
  • 5.6. The FallbackHeaders GatewayFilter Factory
  • +
  • 5.7. The MapRequestHeader GatewayFilter Factory
  • +
  • 5.8. The PrefixPath GatewayFilter Factory
  • +
  • 5.9. The PreserveHostHeader GatewayFilter Factory
  • +
  • 5.10. The RequestRateLimiter GatewayFilter Factory
  • -
  • 5.12. The RedirectTo GatewayFilter Factory
  • -
  • 5.13. The RemoveHopByHopHeadersFilter GatewayFilter Factory
  • -
  • 5.14. The RemoveRequestHeader GatewayFilter Factory
  • -
  • 5.15. RemoveResponseHeader GatewayFilter Factory
  • -
  • 5.16. The RemoveRequestParameter GatewayFilter Factory
  • -
  • 5.17. The RewritePath GatewayFilter Factory
  • -
  • 5.18. RewriteLocationResponseHeader GatewayFilter Factory
  • -
  • 5.19. The RewriteResponseHeader GatewayFilter Factory
  • -
  • 5.20. The SaveSession GatewayFilter Factory
  • -
  • 5.21. The SecureHeaders GatewayFilter Factory
  • -
  • 5.22. The SetPath GatewayFilter Factory
  • -
  • 5.23. The SetRequestHeader GatewayFilter Factory
  • -
  • 5.24. The SetResponseHeader GatewayFilter Factory
  • -
  • 5.25. The SetStatus GatewayFilter Factory
  • -
  • 5.26. The StripPrefix GatewayFilter Factory
  • -
  • 5.27. The Retry GatewayFilter Factory
  • -
  • 5.28. The RequestSize GatewayFilter Factory
  • -
  • 5.29. Modify a Request Body GatewayFilter Factory
  • -
  • 5.30. Modify a Response Body GatewayFilter Factory
  • -
  • 5.31. Default Filters
  • +
  • 5.11. The RedirectTo GatewayFilter Factory
  • +
  • 5.12. The RemoveHopByHopHeadersFilter GatewayFilter Factory
  • +
  • 5.13. The RemoveRequestHeader GatewayFilter Factory
  • +
  • 5.14. RemoveResponseHeader GatewayFilter Factory
  • +
  • 5.15. The RemoveRequestParameter GatewayFilter Factory
  • +
  • 5.16. The RewritePath GatewayFilter Factory
  • +
  • 5.17. RewriteLocationResponseHeader GatewayFilter Factory
  • +
  • 5.18. The RewriteResponseHeader GatewayFilter Factory
  • +
  • 5.19. The SaveSession GatewayFilter Factory
  • +
  • 5.20. The SecureHeaders GatewayFilter Factory
  • +
  • 5.21. The SetPath GatewayFilter Factory
  • +
  • 5.22. The SetRequestHeader GatewayFilter Factory
  • +
  • 5.23. The SetResponseHeader GatewayFilter Factory
  • +
  • 5.24. The SetStatus GatewayFilter Factory
  • +
  • 5.25. The StripPrefix GatewayFilter Factory
  • +
  • 5.26. The Retry GatewayFilter Factory
  • +
  • 5.27. The RequestSize GatewayFilter Factory
  • +
  • 5.28. Modify a Request Body GatewayFilter Factory
  • +
  • 5.29. Modify a Response Body GatewayFilter Factory
  • +
  • 5.30. Default Filters
  • 6. Global Filters @@ -231,7 +230,7 @@ $(addBlockSwitches);
    -

    2.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 are RETAIN_FIRST (default), RETAIN_LAST
  • - - - - -
    - - -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:

    -
    -
    -
    Example 20. application.yml
    -
    -
    -
    -
    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:

    -
    -
    -
    Example 21. application.yml
    -
    -
    -
    -
    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:

    -
    -
    -
    Example 22. application.yml
    -
    -
    -
    -
    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:

    -
    -
    -
    Example 23. application.yml
    -
    -
    -
    -
    hystrix.command.fallbackcmd.execution.isolation.thread.timeoutInMilliseconds: 5000
    -
    -
    -
    -
    -
    -
    -

    5.6. Spring Cloud CircuitBreaker GatewayFilter Factory

    +

    5.5. Spring Cloud CircuitBreaker GatewayFilter Factory

    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:

    -
    Example 24. application.yml
    +
    Example 20. application.yml
    @@ -1179,7 +1043,7 @@ If the fallback is called, the request is forwarded to the controller matched by The following example configures such a fallback:

    -
    Example 25. application.yml
    +
    Example 21. application.yml
    @@ -1205,7 +1069,7 @@ The following example configures such a fallback:

    The following listing does the same thing in Java:

    -
    Example 26. Application.java
    +
    Example 22. Application.java
    @@ -1230,7 +1094,7 @@ Note that this example also demonstrates the (optional) Spring Cloud Netflix Rib However, you can also reroute the request to a controller or handler in an external application, as follows:

    -
    Example 27. application.yml
    +
    Example 23. application.yml
    @@ -1269,12 +1133,12 @@ You can find more information on doing so in the Fa
    -

    5.7. The FallbackHeaders GatewayFilter Factory

    +

    5.6. The FallbackHeaders GatewayFilter Factory

    The 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:

    -
    Example 28. application.yml
    +
    Example 24. application.yml
    @@ -1331,7 +1195,7 @@ The headers with the exception type, message and (if available) root cause excep
    -

    5.8. The MapRequestHeader GatewayFilter Factory

    +

    5.7. The 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. @@ -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:

    -
    Example 29. application.yml
    +
    Example 25. application.yml
    @@ -1361,13 +1225,13 @@ The following example configures a MapRequestHeader:

    -

    5.9. The PrefixPath GatewayFilter Factory

    +

    5.8. The PrefixPath GatewayFilter Factory

    The PrefixPath GatewayFilter factory takes a single prefix parameter. The following example configures a PrefixPath GatewayFilter:

    -
    Example 30. application.yml
    +
    Example 26. application.yml
    @@ -1389,14 +1253,14 @@ So a request to /hello would be sent to /mypath/hello.
    -

    5.10. The PreserveHostHeader GatewayFilter Factory

    +

    5.9. The PreserveHostHeader GatewayFilter Factory

    The 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:

    -
    Example 31. application.yml
    +
    Example 27. application.yml
    @@ -1414,7 +1278,7 @@ The following example configures a PreserveHostHeader Gateway
    -

    5.11. The RequestRateLimiter GatewayFilter Factory

    +

    5.10. The RequestRateLimiter GatewayFilter Factory

    The 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.

    @@ -1428,7 +1292,7 @@ In configuration, reference the bean by name using SpEL. The following listing shows the KeyResolver interface:

    -
    Example 32. KeyResolver.java
    +
    Example 28. KeyResolver.java
    @@ -1461,7 +1325,7 @@ You can adjust this behavior by setting the spring.cloud.gateway.filter.re

    The RequestRateLimiter is not configurable with the "shortcut" notation. The following example below is invalid:

    -
    Example 33. application.properties
    +
    Example 29. application.properties
    @@ -1476,7 +1340,7 @@ spring.cloud.gateway.routes[0].filters[0]=RequestRateLimiter=2, 2, #{@userkeyres
    -

    5.11.1. The Redis RateLimiter

    +

    5.10.1. The 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.

    @@ -1500,7 +1364,7 @@ In this case, the rate limiter needs to be allowed some time between bursts (acc The following listing configures a redis-rate-limiter:

    -
    Example 34. application.yml
    +
    Example 30. application.yml
    @@ -1523,7 +1387,7 @@ The following listing configures a redis-rate-limiter:

    The following example configures a KeyResolver in Java:

    -
    Example 35. Config.java
    +
    Example 31. Config.java
    @@ -1546,7 +1410,7 @@ In configuration, you can reference the bean by name using SpEL. The following listing defines a rate limiter that uses the KeyResolver defined in the previous listing:

    -
    Example 36. application.yml
    +
    Example 32. application.yml
    @@ -1568,7 +1432,7 @@ The following listing defines a rate limiter that uses the KeyResolver
    -

    5.12. The RedirectTo GatewayFilter Factory

    +

    5.11. The RedirectTo GatewayFilter Factory

    The 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:

    -
    Example 37. application.yml
    +
    Example 33. application.yml
    @@ -1599,7 +1463,7 @@ The following listing configures a RedirectTo GatewayFilter
    -

    5.13. The RemoveHopByHopHeadersFilter GatewayFilter Factory

    +

    5.12. The RemoveHopByHopHeadersFilter GatewayFilter Factory

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

    @@ -1638,14 +1502,14 @@ The default list of headers that is removed comes from the -

    5.14. The RemoveRequestHeader GatewayFilter Factory

    +

    5.13. The RemoveRequestHeader GatewayFilter Factory

    The RemoveRequestHeader GatewayFilter factory takes a name parameter. It is the name of the header to be removed. The following listing configures a RemoveRequestHeader GatewayFilter:

    -
    Example 38. application.yml
    +
    Example 34. application.yml
    @@ -1666,14 +1530,14 @@ The following listing configures a RemoveRequestHeader Gatewa
    -

    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. The following listing configures a RemoveResponseHeader GatewayFilter:

    -
    Example 39. application.yml
    +
    Example 35. application.yml
    @@ -1698,14 +1562,14 @@ In addition, you can configure this filter once by using spring.cloud.gate
    -

    5.16. The RemoveRequestParameter GatewayFilter Factory

    +

    5.15. The RemoveRequestParameter GatewayFilter Factory

    The 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:

    -
    Example 40. application.yml
    +
    Example 36. application.yml
    @@ -1726,14 +1590,14 @@ The following example configures a RemoveRequestParameter Gat
    -

    5.17. The RewritePath GatewayFilter Factory

    +

    5.16. The 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. The following listing configures a RewritePath GatewayFilter:

    -
    Example 41. application.yml
    +
    Example 37. application.yml
    @@ -1756,14 +1620,14 @@ The following listing configures a RewritePath GatewayFilter<
    -

    5.18. RewriteLocationResponseHeader GatewayFilter Factory

    +

    5.17. RewriteLocationResponseHeader GatewayFilter Factory

    The 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:

    -
    Example 42. application.yml
    +
    Example 38. application.yml
    @@ -1809,14 +1673,14 @@ The default is http|https|ftp|ftps.

    -

    5.19. The RewriteResponseHeader GatewayFilter Factory

    +

    5.18. The 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. The following example configures a RewriteResponseHeader GatewayFilter:

    -
    Example 43. application.yml
    +
    Example 39. application.yml
    @@ -1838,14 +1702,14 @@ You must use $\ to mean $ because of the YAML specific
    -

    5.20. The SaveSession GatewayFilter Factory

    +

    5.19. The 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 you need to ensure the session state has been saved before making the forwarded call. The following example configures a SaveSession GatewayFilter:

    -
    Example 44. application.yml
    +
    Example 40. application.yml
    @@ -1868,7 +1732,7 @@ The following example configures a SaveSession GatewayFilter<
    -

    5.21. The SecureHeaders GatewayFilter Factory

    +

    5.20. The SecureHeaders GatewayFilter Factory

    The SecureHeaders GatewayFilter factory adds a number of headers to the response, per the recommendation made in this blog post.

    @@ -1962,7 +1826,7 @@ The lowercase full name of the secure header needs to be used to disable it..
    -

    5.22. The SetPath GatewayFilter Factory

    +

    5.21. The 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. @@ -1971,7 +1835,7 @@ Multiple matching segments are allowed. The following example configures a SetPath GatewayFilter:

    -
    Example 45. application.yml
    +
    Example 41. application.yml
    @@ -1994,13 +1858,13 @@ The following example configures a SetPath GatewayFilter
    -

    5.23. The SetRequestHeader GatewayFilter Factory

    +

    5.22. The SetRequestHeader GatewayFilter Factory

    The SetRequestHeader GatewayFilter factory takes name and value parameters. The following listing configures a SetRequestHeader GatewayFilter:

    -
    Example 46. application.yml
    +
    Example 42. application.yml
    @@ -2026,7 +1890,7 @@ URI variables may be used in the value and are expanded at runtime. The following example configures an SetRequestHeader GatewayFilter that uses a variable:

    -
    Example 47. application.yml
    +
    Example 43. application.yml
    @@ -2046,13 +1910,13 @@ The following example configures an SetRequestHeader GatewayF
    -

    5.24. The SetResponseHeader GatewayFilter Factory

    +

    5.23. The SetResponseHeader GatewayFilter Factory

    The SetResponseHeader GatewayFilter factory takes name and value parameters. The following listing configures a SetResponseHeader GatewayFilter:

    -
    Example 48. application.yml
    +
    Example 44. application.yml
    @@ -2078,7 +1942,7 @@ URI variables may be used in the value and will be expanded at runtime. The following example configures an SetResponseHeader GatewayFilter that uses a variable:

    -
    Example 49. application.yml
    +
    Example 45. application.yml
    @@ -2098,7 +1962,7 @@ The following example configures an SetResponseHeader Gateway
    -

    5.25. The SetStatus GatewayFilter Factory

    +

    5.24. The SetStatus GatewayFilter Factory

    The 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:

    -
    Example 50. application.yml
    +
    Example 46. application.yml
    @@ -2134,7 +1998,7 @@ The following listing configures a SetStatus GatewayFilter
    -
    Example 51. application.yml
    +
    Example 47. application.yml
    @@ -2149,14 +2013,14 @@ The header is added to the response if configured with the following property:
    -

    5.26. The StripPrefix GatewayFilter Factory

    +

    5.25. The StripPrefix GatewayFilter Factory

    The 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:

    -
    Example 52. application.yml
    +
    Example 48. application.yml
    @@ -2179,7 +2043,7 @@ The following listing configures a StripPrefix GatewayFilter<
    -

    5.27. The Retry GatewayFilter Factory

    +

    5.26. The Retry GatewayFilter Factory

    The Retry GatewayFilter factory supports the following parameters:

    @@ -2234,7 +2098,7 @@ If basedOnPreviousValue is true, the backoff is calculated byusing

    The following listing configures a Retry GatewayFilter:

    -
    Example 53. application.yml
    +
    Example 49. application.yml
    @@ -2288,7 +2152,7 @@ Instead, it should throw an Exception or signal an error (for examp
    -

    5.28. The RequestSize GatewayFilter Factory

    +

    5.27. The RequestSize GatewayFilter Factory

    When 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:

    -
    Example 54. application.yml
    +
    Example 50. application.yml
    @@ -2342,7 +2206,7 @@ The default request size is set to five MB if not provided as a filter argument
    -

    5.29. Modify a Request Body GatewayFilter Factory

    +

    5.28. Modify a Request Body GatewayFilter Factory

    @@ -2410,7 +2274,7 @@ static class Hello {
    @@ -2460,14 +2324,14 @@ public RouteLocator routes(RouteLocatorBuilder builder) {
    -

    5.31. Default Filters

    +

    5.30. Default Filters

    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. The following listing defines a set of default filters:

    -
    Example 55. application.yml
    +
    Example 51. application.yml
    @@ -2516,7 +2380,7 @@ This combined filter chain is sorted by the org.springframework.core.Order

    The following listing configures a filter chain:

    -
    Example 56. ExampleConfiguration.java
    +
    Example 52. ExampleConfiguration.java
    @@ -2563,7 +2427,7 @@ If so, the same rules apply. The following listing configures a LoadBalancerClientFilter:

    -
    Example 57. application.yml
    +
    Example 53. application.yml
    @@ -2638,7 +2502,7 @@ If so, the same rules apply. The following listing configures a ReactiveLoadBalancerClientFilter:

    -
    Example 58. application.yml
    +
    Example 54. application.yml
    @@ -2736,7 +2600,7 @@ If you use SockJS as a fallback over nor

    The following listing configures a websocket routing filter:

    -
    Example 59. application.yml
    +
    Example 55. application.yml
    @@ -2831,7 +2695,7 @@ or check if an exchange has already been routed.

    The following example shows how to do so:

    -
    Example 60. application.yml
    +
    Example 56. application.yml
    @@ -2851,7 +2715,7 @@ The following example shows how to do so:

    If you are routing to an HTTPS backend, you can configure the gateway to trust all downstream certificates with the following configuration:

    -
    Example 61. application.yml
    +
    Example 57. application.yml
    @@ -2870,7 +2734,7 @@ If you are routing to an HTTPS backend, you can configure the gateway to trust a For a production deployment, you can configure the gateway with a set of known certificates that it can trust with the following configuration:

    -
    Example 62. application.yml
    +
    Example 58. application.yml
    @@ -2898,7 +2762,7 @@ A number of timeouts are associated with this handshake. You can configure these timeouts can be configured (defaults shown) as follows:

    -
    Example 63. application.yml
    +
    Example 59. application.yml
    @@ -2925,7 +2789,7 @@ You can configure these timeouts can be configured (defaults shown) as follows:< The following listing shows the definition of the RouteDefinitionLocator interface:

    -
    Example 64. RouteDefinitionLocator.java
    +
    Example 60. RouteDefinitionLocator.java
    @@ -2944,7 +2808,7 @@ The following listing shows the definition of the RouteDefinitionLocator
    -
    Example 65. application.yml
    +
    Example 61. application.yml
    @@ -2978,7 +2842,7 @@ The following two examples are equivalent:

    You can configure additional parameters for each route by using metadata, as follows:

    -
    Example 66. application.yml
    +
    Example 62. application.yml
    @@ -3089,7 +2953,7 @@ import static org.springframework.cloud.gateway.support.RouteMetadataUtils.RESPO The following listing shows how it works:

    -
    Example 67. GatewaySampleApplication.java
    +
    Example 63. GatewaySampleApplication.java
    @@ -3156,7 +3020,7 @@ When doing so, you need to make sure to include the default predicate and filter The following example shows what this looks like:

    -
    Example 68. application.properties
    +
    Example 64. application.properties
    @@ -3199,7 +3063,7 @@ It must be a Java System Property, not a Spring Boot property.

    You can configure the logging system to have a separate access log file. The following example creates a Logback configuration: