spring:
+ cloud:
+ gateway:
+ httpclient:
+ connect-timeout: 1000
+ response-timeout: 5s
+diff --git a/reference/html/index.html b/reference/html/index.html index 95aad5d1..7d76c6df 100644 --- a/reference/html/index.html +++ b/reference/html/index.html @@ -177,50 +177,53 @@ $(addBlockSwitches);
Http timeouts (response and connect) can be configured for all routes and overridden for each specific route.
+To configure Global http timeouts:
+connect-timeout must be specified in milliseconds.
+response-timeout must be specified as a java.time.Duration
spring:
+ cloud:
+ gateway:
+ httpclient:
+ connect-timeout: 1000
+ response-timeout: 5s
+To configure per-route timeouts:
+connect-timeout must be specified in milliseconds.
+response-timeout must be specified in milliseconds.
- id: per_route_timeouts
+ uri: https://example.org
+ predicates:
+ - name: Path
+ args:
+ pattern: /delay/{timeout}
+ metadata:
+ response-timeout: 200
+ connect-timeout: 200
+import static org.springframework.cloud.gateway.support.RouteMetadataUtils.CONNECT_TIMEOUT_ATTR;
+import static org.springframework.cloud.gateway.support.RouteMetadataUtils.RESPONSE_TIMEOUT_ATTR;
+
+ @Bean
+ public RouteLocator customRouteLocator(RouteLocatorBuilder routeBuilder){
+ return routeBuilder.routes()
+ .route("test1", r -> {
+ return r.host("*.somehost.org").and().path("/somepath")
+ .filters(f -> f.addRequestHeader("header1", "header-value-1"))
+ .uri("http://someuri")
+ .metadata(RESPONSE_TIMEOUT_ATTR, 200)
+ .metadata(CONNECT_TIMEOUT_ATTR, 200);
+ })
+ .build();
+ }
+To allow for simple configuration in Java, there is a fluent API defined in the RouteLocatorBuilder bean.
The Gateway can be configured to create routes based on services registered with a DiscoveryClient compatible service registry.
To enable this, set spring.cloud.gateway.discovery.locator.enabled=true and make sure a DiscoveryClient implementation is on the classpath and enabled (such as Netflix Eureka, Consul or Zookeeper).
By default the Gateway defines a single predicate and filter for routes created via a DiscoveryClient.
To enable Reactor Netty access logs, set -Dreactor.netty.http.server.accessLogEnabled=true. (It must be a Java System Property, not a Spring Boot property).
The gateway can be configured to control CORS behavior. The "global" CORS configuration is a map of URL patterns to Spring Framework CorsConfiguration.
The /gateway actuator endpoint allows to monitor and interact with a Spring Cloud Gateway application. To be remotely accessible, the endpoint has to be enabled and exposed via HTTP or JMX in the application properties.
A new, more verbose format has been added to Gateway. This adds more detail to each route allowing to view the predicates and filters associated to each route along with any configuration that is available.
To retrieve the global filters applied to all routes, make a GET request to /actuator/gateway/globalfilters. The resulting response is similar to the following:
To retrieve the GatewayFilter factories applied to routes, make a GET request to /actuator/gateway/routefilters. The resulting response is similar to the following:
To clear the routes cache, make a POST request to /actuator/gateway/refresh. The request returns a 200 without response body.
To retrieve the routes defined in the gateway, make a GET request to /actuator/gateway/routes. The resulting response is similar to the following:
To retrieve information about a single route, make a GET request to /actuator/gateway/routes/{id} (e.g., /actuator/gateway/routes/first_route). The resulting response is similar to the following:
To create a route, make a POST request to /gateway/routes/{id_route_to_create} with a JSON body that specifies the fields of the route (see the previous subsection).
The table below summarises the Spring Cloud Gateway actuator endpoints. Note that each endpoint has /actuator/gateway as the base-path.
Below are some useful loggers that contain valuable trouble shooting infomration at the DEBUG and TRACE levels.
The Reactor Netty HttpClient and HttpServer can have wiretap enabled. When combined
with setting the reactor.netty log level to DEBUG or TRACE will enable logging of
@@ -2980,19 +3052,19 @@ respectively.
TODO: overview of writing custom integrations
TODO: document writing Custom Route Predicate Factories
In order to write a GatewayFilter you will need to implement GatewayFilterFactory. There is an abstract class called AbstractGatewayFilterFactory which you can extend.
In order to write a custom global filter, you will need to implement GlobalFilter interface. This will apply the filter to all requests.
TODO: document writing Custom Route Locators and Writers
Spring Cloud Gateway provides a utility object called ProxyExchange which you can use inside a regular Spring web handler as a method parameter. It supports basic downstream HTTP exchanges via methods that mirror the HTTP verbs. With MVC it also supports forwarding to a local handler via the forward() method. To use the ProxyExchange just include the right module in your classpath (either spring-cloud-gateway-mvc or spring-cloud-gateway-webflux).
To see the list of all Spring Cloud Gateway related configuration properties please check the Appendix page.
diff --git a/reference/html/spring-cloud-gateway.html b/reference/html/spring-cloud-gateway.html index 95aad5d1..7d76c6df 100644 --- a/reference/html/spring-cloud-gateway.html +++ b/reference/html/spring-cloud-gateway.html @@ -177,50 +177,53 @@ $(addBlockSwitches);Http timeouts (response and connect) can be configured for all routes and overridden for each specific route.
+To configure Global http timeouts:
+connect-timeout must be specified in milliseconds.
+response-timeout must be specified as a java.time.Duration
spring:
+ cloud:
+ gateway:
+ httpclient:
+ connect-timeout: 1000
+ response-timeout: 5s
+To configure per-route timeouts:
+connect-timeout must be specified in milliseconds.
+response-timeout must be specified in milliseconds.
- id: per_route_timeouts
+ uri: https://example.org
+ predicates:
+ - name: Path
+ args:
+ pattern: /delay/{timeout}
+ metadata:
+ response-timeout: 200
+ connect-timeout: 200
+import static org.springframework.cloud.gateway.support.RouteMetadataUtils.CONNECT_TIMEOUT_ATTR;
+import static org.springframework.cloud.gateway.support.RouteMetadataUtils.RESPONSE_TIMEOUT_ATTR;
+
+ @Bean
+ public RouteLocator customRouteLocator(RouteLocatorBuilder routeBuilder){
+ return routeBuilder.routes()
+ .route("test1", r -> {
+ return r.host("*.somehost.org").and().path("/somepath")
+ .filters(f -> f.addRequestHeader("header1", "header-value-1"))
+ .uri("http://someuri")
+ .metadata(RESPONSE_TIMEOUT_ATTR, 200)
+ .metadata(CONNECT_TIMEOUT_ATTR, 200);
+ })
+ .build();
+ }
+To allow for simple configuration in Java, there is a fluent API defined in the RouteLocatorBuilder bean.
The Gateway can be configured to create routes based on services registered with a DiscoveryClient compatible service registry.
To enable this, set spring.cloud.gateway.discovery.locator.enabled=true and make sure a DiscoveryClient implementation is on the classpath and enabled (such as Netflix Eureka, Consul or Zookeeper).
By default the Gateway defines a single predicate and filter for routes created via a DiscoveryClient.
To enable Reactor Netty access logs, set -Dreactor.netty.http.server.accessLogEnabled=true. (It must be a Java System Property, not a Spring Boot property).
The gateway can be configured to control CORS behavior. The "global" CORS configuration is a map of URL patterns to Spring Framework CorsConfiguration.
The /gateway actuator endpoint allows to monitor and interact with a Spring Cloud Gateway application. To be remotely accessible, the endpoint has to be enabled and exposed via HTTP or JMX in the application properties.
A new, more verbose format has been added to Gateway. This adds more detail to each route allowing to view the predicates and filters associated to each route along with any configuration that is available.
To retrieve the global filters applied to all routes, make a GET request to /actuator/gateway/globalfilters. The resulting response is similar to the following:
To retrieve the GatewayFilter factories applied to routes, make a GET request to /actuator/gateway/routefilters. The resulting response is similar to the following:
To clear the routes cache, make a POST request to /actuator/gateway/refresh. The request returns a 200 without response body.
To retrieve the routes defined in the gateway, make a GET request to /actuator/gateway/routes. The resulting response is similar to the following:
To retrieve information about a single route, make a GET request to /actuator/gateway/routes/{id} (e.g., /actuator/gateway/routes/first_route). The resulting response is similar to the following:
To create a route, make a POST request to /gateway/routes/{id_route_to_create} with a JSON body that specifies the fields of the route (see the previous subsection).
The table below summarises the Spring Cloud Gateway actuator endpoints. Note that each endpoint has /actuator/gateway as the base-path.
Below are some useful loggers that contain valuable trouble shooting infomration at the DEBUG and TRACE levels.
The Reactor Netty HttpClient and HttpServer can have wiretap enabled. When combined
with setting the reactor.netty log level to DEBUG or TRACE will enable logging of
@@ -2980,19 +3052,19 @@ respectively.
TODO: overview of writing custom integrations
TODO: document writing Custom Route Predicate Factories
In order to write a GatewayFilter you will need to implement GatewayFilterFactory. There is an abstract class called AbstractGatewayFilterFactory which you can extend.
In order to write a custom global filter, you will need to implement GlobalFilter interface. This will apply the filter to all requests.
TODO: document writing Custom Route Locators and Writers
Spring Cloud Gateway provides a utility object called ProxyExchange which you can use inside a regular Spring web handler as a method parameter. It supports basic downstream HTTP exchanges via methods that mirror the HTTP verbs. With MVC it also supports forwarding to a local handler via the forward() method. To use the ProxyExchange just include the right module in your classpath (either spring-cloud-gateway-mvc or spring-cloud-gateway-webflux).
To see the list of all Spring Cloud Gateway related configuration properties please check the Appendix page.