diff --git a/multi/multi__actuator_api.html b/multi/multi__actuator_api.html index b85a2b3d..f6f2de9e 100644 --- a/multi/multi__actuator_api.html +++ b/multi/multi__actuator_api.html @@ -1,3 +1,45 @@ - 11. Actuator API

11. Actuator API

TODO: document the /gateway actuator endpoint

\ No newline at end of file + 11. Actuator API

11. Actuator API

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.

application.properties.  +

management.endpoint.gateway.enabled=true # default value
+management.endpoints.web.exposure.include=gateway

+

11.1 Retrieving route filters

11.1.1 Global Filters

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:

{
+  "org.springframework.cloud.gateway.filter.LoadBalancerClientFilter@77856cc5": 10100,
+  "org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter@4f6fd101": 10000,
+  "org.springframework.cloud.gateway.filter.NettyWriteResponseFilter@32d22650": -1,
+  "org.springframework.cloud.gateway.filter.ForwardRoutingFilter@106459d9": 2147483647,
+  "org.springframework.cloud.gateway.filter.NettyRoutingFilter@1fbd5e0": 2147483647,
+  "org.springframework.cloud.gateway.filter.ForwardPathFilter@33a71d23": 0,
+  "org.springframework.cloud.gateway.filter.AdaptCachedBodyGlobalFilter@135064ea": 2147483637,
+  "org.springframework.cloud.gateway.filter.WebsocketRoutingFilter@23c05889": 2147483646
+}

The response contains details of the global filters in place. For each global filter is provided the string representation of the filter object (e.g., org.springframework.cloud.gateway.filter.LoadBalancerClientFilter@77856cc5) and the corresponding order in the filter chain.

11.1.2 Route Filters

To retrieve the GatewayFilter factories applied to routes, make a GET request to /actuator/gateway/routefilters. The resulting response is similar to the following:

{
+  "[AddRequestHeaderGatewayFilterFactory@570ed9c configClass = AbstractNameValueGatewayFilterFactory.NameValueConfig]": null,
+  "[SecureHeadersGatewayFilterFactory@fceab5d configClass = Object]": null,
+  "[SaveSessionGatewayFilterFactory@4449b273 configClass = Object]": null
+}

The response contains details of the GatewayFilter factories applied to any particular route. For each factory is provided the string representation of the corresponding object (e.g., [SecureHeadersGatewayFilterFactory@fceab5d configClass = Object]). Note that the null value is due to an incomplete implementation of the endpoint controller, for that it tries to set the order of the object in the filter chain, which does not apply to a GatewayFilter factory object.

11.2 Refreshing the route cache

To clear the routes cache, make a POST request to /actuator/gateway/refresh. The request returns a 200 without response body.

11.3 Retrieving the routes defined in the gateway

To retrieve the routes defined in the gateway, make a GET request to /actuator/gateway/routes. The resulting response is similar to the following:

[{
+  "route_id": "first_route",
+  "route_object": {
+    "predicate": "org.springframework.cloud.gateway.handler.predicate.PathRoutePredicateFactory$$Lambda$432/1736826640@1e9d7e7d",
+    "filters": [
+      "OrderedGatewayFilter{delegate=org.springframework.cloud.gateway.filter.factory.PreserveHostHeaderGatewayFilterFactory$$Lambda$436/674480275@6631ef72, order=0}"
+    ]
+  },
+  "order": 0
+},
+{
+  "route_id": "second_route",
+  "route_object": {
+    "predicate": "org.springframework.cloud.gateway.handler.predicate.PathRoutePredicateFactory$$Lambda$432/1736826640@cd8d298",
+    "filters": []
+  },
+  "order": 0
+}]

The response contains details of all the routes defined in the gateway. The following table describes the structure of each element (i.e., a route) of the response.

PathTypeDescription

route_id

String

The route id.

route_object.predicate

Object

The route predicate.

route_object.filters

Array

The GatewayFilter factories applied to the route.

order

Number

The route order.

11.4 Retrieving information about a particular route

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:

{
+  "id": "first_route",
+  "predicates": [{
+    "name": "Path",
+    "args": {"_genkey_0":"/first"}
+  }],
+  "filters": [],
+  "uri": "http://www.uri-destination.org",
+  "order": 0
+}]

The following table describes the structure of the response.

PathTypeDescription

id

String

The route id.

predicates

Array

The collection of route predicates. Each item defines the name and the arguments of a given predicate.

filters

Array

The collection of filters applied to the route.

uri

String

The destination URI of the route.

order

Number

The route order.

11.5 Creating and deleting a particular route

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

To delete a route, make a DELETE request to /gateway/routes/{id_route_to_delete}.

11.6 Recap: list of all endpoints

The table below summarises the Spring Cloud Gateway actuator endpoints. Note that each endpoint has /actuator/gateway as the base-path.

IDHTTP MethodDescription

globalfilters

GET

Displays the list of global filters applied to the routes.

routefilters

GET

Displays the list of GatewayFilter factories applied to a particular route.

refresh

POST

Clears the routes cache.

routes

GET

Displays the list of routes defined in the gateway.

routes/{id}

GET

Displays information about a particular route.

routes/{id}

POST

Add a new route to the gateway.

routes/{id}

DELETE

Remove an existing route from the gateway.

\ No newline at end of file diff --git a/multi/multi_spring-cloud-gateway.html b/multi/multi_spring-cloud-gateway.html index bb3323fa..9157480c 100644 --- a/multi/multi_spring-cloud-gateway.html +++ b/multi/multi_spring-cloud-gateway.html @@ -1,3 +1,3 @@ - Spring Cloud Gateway

Spring Cloud Gateway


Table of Contents

1. How to Include Spring Cloud Gateway
2. Glossary
3. How It Works
4. Route Predicate Factories
4.1. After Route Predicate Factory
4.2. Before Route Predicate Factory
4.3. Between Route Predicate Factory
4.4. Cookie Route Predicate Factory
4.5. Header Route Predicate Factory
4.6. Host Route Predicate Factory
4.7. Method Route Predicate Factory
4.8. Path Route Predicate Factory
4.9. Query Route Predicate Factory
4.10. RemoteAddr Route Predicate Factory
4.10.1. Modifying the way remote addresses are resolved
5. GatewayFilter Factories
5.1. AddRequestHeader GatewayFilter Factory
5.2. AddRequestParameter GatewayFilter Factory
5.3. AddResponseHeader GatewayFilter Factory
5.4. Hystrix GatewayFilter Factory
5.5. FallbackHeaders GatewayFilter Factory
5.6. PrefixPath GatewayFilter Factory
5.7. PreserveHostHeader GatewayFilter Factory
5.8. RequestRateLimiter GatewayFilter Factory
5.8.1. Redis RateLimiter
5.9. RedirectTo GatewayFilter Factory
5.10. RemoveNonProxyHeaders GatewayFilter Factory
5.11. RemoveRequestHeader GatewayFilter Factory
5.12. RemoveResponseHeader GatewayFilter Factory
5.13. RewritePath GatewayFilter Factory
5.14. RewriteResponseHeader GatewayFilter Factory
5.15. SaveSession GatewayFilter Factory
5.16. SecureHeaders GatewayFilter Factory
5.17. SetPath GatewayFilter Factory
5.18. SetResponseHeader GatewayFilter Factory
5.19. SetStatus GatewayFilter Factory
5.20. StripPrefix GatewayFilter Factory
5.21. Retry GatewayFilter Factory
5.22. RequestSize GatewayFilter Factory
6. Global Filters
6.1. Combined Global Filter and GatewayFilter Ordering
6.2. Forward Routing Filter
6.3. LoadBalancerClient Filter
6.4. Netty Routing Filter
6.5. Netty Write Response Filter
6.6. RouteToRequestUrl Filter
6.7. Websocket Routing Filter
6.8. Gateway Metrics Filter
6.9. Making An Exchange As Routed
7. TLS / SSL
7.1. TLS Handshake
8. Configuration
8.1. Fluent Java Routes API
8.2. DiscoveryClient Route Definition Locator
9. Reactor Netty Access Logs
10. CORS Configuration
11. Actuator API
12. Developer Guide
12.1. Writing Custom Route Predicate Factories
12.2. Writing Custom GatewayFilter Factories
12.3. Writing Custom Global Filters
12.4. Writing Custom Route Locators and Writers
13. Building a Simple Gateway Using Spring MVC or Webflux
\ No newline at end of file + Spring Cloud Gateway

Spring Cloud Gateway


Table of Contents

1. How to Include Spring Cloud Gateway
2. Glossary
3. How It Works
4. Route Predicate Factories
4.1. After Route Predicate Factory
4.2. Before Route Predicate Factory
4.3. Between Route Predicate Factory
4.4. Cookie Route Predicate Factory
4.5. Header Route Predicate Factory
4.6. Host Route Predicate Factory
4.7. Method Route Predicate Factory
4.8. Path Route Predicate Factory
4.9. Query Route Predicate Factory
4.10. RemoteAddr Route Predicate Factory
4.10.1. Modifying the way remote addresses are resolved
5. GatewayFilter Factories
5.1. AddRequestHeader GatewayFilter Factory
5.2. AddRequestParameter GatewayFilter Factory
5.3. AddResponseHeader GatewayFilter Factory
5.4. Hystrix GatewayFilter Factory
5.5. FallbackHeaders GatewayFilter Factory
5.6. PrefixPath GatewayFilter Factory
5.7. PreserveHostHeader GatewayFilter Factory
5.8. RequestRateLimiter GatewayFilter Factory
5.8.1. Redis RateLimiter
5.9. RedirectTo GatewayFilter Factory
5.10. RemoveNonProxyHeaders GatewayFilter Factory
5.11. RemoveRequestHeader GatewayFilter Factory
5.12. RemoveResponseHeader GatewayFilter Factory
5.13. RewritePath GatewayFilter Factory
5.14. RewriteResponseHeader GatewayFilter Factory
5.15. SaveSession GatewayFilter Factory
5.16. SecureHeaders GatewayFilter Factory
5.17. SetPath GatewayFilter Factory
5.18. SetResponseHeader GatewayFilter Factory
5.19. SetStatus GatewayFilter Factory
5.20. StripPrefix GatewayFilter Factory
5.21. Retry GatewayFilter Factory
5.22. RequestSize GatewayFilter Factory
6. Global Filters
6.1. Combined Global Filter and GatewayFilter Ordering
6.2. Forward Routing Filter
6.3. LoadBalancerClient Filter
6.4. Netty Routing Filter
6.5. Netty Write Response Filter
6.6. RouteToRequestUrl Filter
6.7. Websocket Routing Filter
6.8. Gateway Metrics Filter
6.9. Making An Exchange As Routed
7. TLS / SSL
7.1. TLS Handshake
8. Configuration
8.1. Fluent Java Routes API
8.2. DiscoveryClient Route Definition Locator
9. Reactor Netty Access Logs
10. CORS Configuration
11. Actuator API
11.1. Retrieving route filters
11.1.1. Global Filters
11.1.2. Route Filters
11.2. Refreshing the route cache
11.3. Retrieving the routes defined in the gateway
11.4. Retrieving information about a particular route
11.5. Creating and deleting a particular route
11.6. Recap: list of all endpoints
12. Developer Guide
12.1. Writing Custom Route Predicate Factories
12.2. Writing Custom GatewayFilter Factories
12.3. Writing Custom Global Filters
12.4. Writing Custom Route Locators and Writers
13. Building a Simple Gateway Using Spring MVC or Webflux
\ No newline at end of file diff --git a/single/spring-cloud-gateway.html b/single/spring-cloud-gateway.html index 5c3b21d7..8f7cb693 100644 --- a/single/spring-cloud-gateway.html +++ b/single/spring-cloud-gateway.html @@ -1,6 +1,6 @@ - Spring Cloud Gateway

Spring Cloud Gateway


Table of Contents

1. How to Include Spring Cloud Gateway
2. Glossary
3. How It Works
4. Route Predicate Factories
4.1. After Route Predicate Factory
4.2. Before Route Predicate Factory
4.3. Between Route Predicate Factory
4.4. Cookie Route Predicate Factory
4.5. Header Route Predicate Factory
4.6. Host Route Predicate Factory
4.7. Method Route Predicate Factory
4.8. Path Route Predicate Factory
4.9. Query Route Predicate Factory
4.10. RemoteAddr Route Predicate Factory
4.10.1. Modifying the way remote addresses are resolved
5. GatewayFilter Factories
5.1. AddRequestHeader GatewayFilter Factory
5.2. AddRequestParameter GatewayFilter Factory
5.3. AddResponseHeader GatewayFilter Factory
5.4. Hystrix GatewayFilter Factory
5.5. FallbackHeaders GatewayFilter Factory
5.6. PrefixPath GatewayFilter Factory
5.7. PreserveHostHeader GatewayFilter Factory
5.8. RequestRateLimiter GatewayFilter Factory
5.8.1. Redis RateLimiter
5.9. RedirectTo GatewayFilter Factory
5.10. RemoveNonProxyHeaders GatewayFilter Factory
5.11. RemoveRequestHeader GatewayFilter Factory
5.12. RemoveResponseHeader GatewayFilter Factory
5.13. RewritePath GatewayFilter Factory
5.14. RewriteResponseHeader GatewayFilter Factory
5.15. SaveSession GatewayFilter Factory
5.16. SecureHeaders GatewayFilter Factory
5.17. SetPath GatewayFilter Factory
5.18. SetResponseHeader GatewayFilter Factory
5.19. SetStatus GatewayFilter Factory
5.20. StripPrefix GatewayFilter Factory
5.21. Retry GatewayFilter Factory
5.22. RequestSize GatewayFilter Factory
6. Global Filters
6.1. Combined Global Filter and GatewayFilter Ordering
6.2. Forward Routing Filter
6.3. LoadBalancerClient Filter
6.4. Netty Routing Filter
6.5. Netty Write Response Filter
6.6. RouteToRequestUrl Filter
6.7. Websocket Routing Filter
6.8. Gateway Metrics Filter
6.9. Making An Exchange As Routed
7. TLS / SSL
7.1. TLS Handshake
8. Configuration
8.1. Fluent Java Routes API
8.2. DiscoveryClient Route Definition Locator
9. Reactor Netty Access Logs
10. CORS Configuration
11. Actuator API
12. Developer Guide
12.1. Writing Custom Route Predicate Factories
12.2. Writing Custom GatewayFilter Factories
12.3. Writing Custom Global Filters
12.4. Writing Custom Route Locators and Writers
13. Building a Simple Gateway Using Spring MVC or Webflux

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

1. How to Include Spring Cloud Gateway

To include Spring Cloud Gateway in your project use the starter with group org.springframework.cloud + Spring Cloud Gateway

Spring Cloud Gateway


Table of Contents

1. How to Include Spring Cloud Gateway
2. Glossary
3. How It Works
4. Route Predicate Factories
4.1. After Route Predicate Factory
4.2. Before Route Predicate Factory
4.3. Between Route Predicate Factory
4.4. Cookie Route Predicate Factory
4.5. Header Route Predicate Factory
4.6. Host Route Predicate Factory
4.7. Method Route Predicate Factory
4.8. Path Route Predicate Factory
4.9. Query Route Predicate Factory
4.10. RemoteAddr Route Predicate Factory
4.10.1. Modifying the way remote addresses are resolved
5. GatewayFilter Factories
5.1. AddRequestHeader GatewayFilter Factory
5.2. AddRequestParameter GatewayFilter Factory
5.3. AddResponseHeader GatewayFilter Factory
5.4. Hystrix GatewayFilter Factory
5.5. FallbackHeaders GatewayFilter Factory
5.6. PrefixPath GatewayFilter Factory
5.7. PreserveHostHeader GatewayFilter Factory
5.8. RequestRateLimiter GatewayFilter Factory
5.8.1. Redis RateLimiter
5.9. RedirectTo GatewayFilter Factory
5.10. RemoveNonProxyHeaders GatewayFilter Factory
5.11. RemoveRequestHeader GatewayFilter Factory
5.12. RemoveResponseHeader GatewayFilter Factory
5.13. RewritePath GatewayFilter Factory
5.14. RewriteResponseHeader GatewayFilter Factory
5.15. SaveSession GatewayFilter Factory
5.16. SecureHeaders GatewayFilter Factory
5.17. SetPath GatewayFilter Factory
5.18. SetResponseHeader GatewayFilter Factory
5.19. SetStatus GatewayFilter Factory
5.20. StripPrefix GatewayFilter Factory
5.21. Retry GatewayFilter Factory
5.22. RequestSize GatewayFilter Factory
6. Global Filters
6.1. Combined Global Filter and GatewayFilter Ordering
6.2. Forward Routing Filter
6.3. LoadBalancerClient Filter
6.4. Netty Routing Filter
6.5. Netty Write Response Filter
6.6. RouteToRequestUrl Filter
6.7. Websocket Routing Filter
6.8. Gateway Metrics Filter
6.9. Making An Exchange As Routed
7. TLS / SSL
7.1. TLS Handshake
8. Configuration
8.1. Fluent Java Routes API
8.2. DiscoveryClient Route Definition Locator
9. Reactor Netty Access Logs
10. CORS Configuration
11. Actuator API
11.1. Retrieving route filters
11.1.1. Global Filters
11.1.2. Route Filters
11.2. Refreshing the route cache
11.3. Retrieving the routes defined in the gateway
11.4. Retrieving information about a particular route
11.5. Creating and deleting a particular route
11.6. Recap: list of all endpoints
12. Developer Guide
12.1. Writing Custom Route Predicate Factories
12.2. Writing Custom GatewayFilter Factories
12.3. Writing Custom Global Filters
12.4. Writing Custom Route Locators and Writers
13. Building a Simple Gateway Using Spring MVC or Webflux

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

1. How to Include Spring Cloud Gateway

To include Spring Cloud Gateway in your project use the starter with group org.springframework.cloud and artifact id spring-cloud-starter-gateway. See the Spring Cloud Project page for details on setting up your build system with the current Spring Cloud Release Train.

If you include the starter, but, for some reason, you do not want the gateway to be enabled, set spring.cloud.gateway.enabled=false.

[Important]Important

Spring Cloud Gateway requires the Netty runtime provided by Spring Boot and Spring Webflux. It does not work in a traditional Servlet Container or built as a WAR.

2. Glossary

  • Route: Route the basic building block of the gateway. It is defined by an ID, a destination URI, a collection of predicates and a collection of filters. A route is matched if aggregate predicate is true.
  • Predicate: This is a Java 8 Function Predicate. The input type is a Spring Framework ServerWebExchange. This allows developers to match on anything from the HTTP request, such as headers or parameters.
  • Filter: These are instances Spring Framework GatewayFilter constructed in with a specific factory. Here, requests and responses can be modified before or after sending the downstream request.

3. How It Works

Spring Cloud Gateway Diagram

Clients make requests to Spring Cloud Gateway. If the Gateway Handler Mapping determines that a request matches a Route, it is sent to the Gateway Web Handler. This handler runs sends the request through a filter chain that is specific to the request. The reason the filters are divided by the dotted line, is that filters may execute logic before the proxy request is sent or after. All "pre" filter logic is executed, then the proxy request is made. After the proxy request is made, the "post" filter logic is executed.

[Note]Note

URIs defined in routes without a port will get a default port set to 80 and 443 for HTTP and HTTPS URIs respectively.

4. Route Predicate Factories

Spring Cloud Gateway matches routes as part of the Spring WebFlux HandlerMapping infrastructure. Spring Cloud Gateway includes many built-in Route Predicate Factories. All of these predicates match on different attributes of the HTTP request. Multiple Route Predicate Factories can be combined and are combined via logical and.

4.1 After Route Predicate Factory

The After Route Predicate Factory takes one parameter, a datetime. This predicate matches requests that happen after the current datetime.

application.yml. 

spring:
@@ -566,7 +566,49 @@ or check if an exchange has already been routed.

allowedOrigins: "docs.spring.io" allowedMethods: - GET

-

In the example above, CORS requests will be allowed from requests that originate from docs.spring.io for all GET requested paths.

11. Actuator API

TODO: document the /gateway actuator endpoint

12. Developer Guide

TODO: overview of writing custom integrations

12.1 Writing Custom Route Predicate Factories

TODO: document writing Custom Route Predicate Factories

12.2 Writing Custom GatewayFilter Factories

In order to write a GatewayFilter you will need to implement GatewayFilterFactory. There is an abstract class called AbstractGatewayFilterFactory which you can extend.

PreGatewayFilterFactory.java.  +

In the example above, CORS requests will be allowed from requests that originate from docs.spring.io for all GET requested paths.

11. Actuator API

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.

application.properties.  +

management.endpoint.gateway.enabled=true # default value
+management.endpoints.web.exposure.include=gateway

+

11.1 Retrieving route filters

11.1.1 Global Filters

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:

{
+  "org.springframework.cloud.gateway.filter.LoadBalancerClientFilter@77856cc5": 10100,
+  "org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter@4f6fd101": 10000,
+  "org.springframework.cloud.gateway.filter.NettyWriteResponseFilter@32d22650": -1,
+  "org.springframework.cloud.gateway.filter.ForwardRoutingFilter@106459d9": 2147483647,
+  "org.springframework.cloud.gateway.filter.NettyRoutingFilter@1fbd5e0": 2147483647,
+  "org.springframework.cloud.gateway.filter.ForwardPathFilter@33a71d23": 0,
+  "org.springframework.cloud.gateway.filter.AdaptCachedBodyGlobalFilter@135064ea": 2147483637,
+  "org.springframework.cloud.gateway.filter.WebsocketRoutingFilter@23c05889": 2147483646
+}

The response contains details of the global filters in place. For each global filter is provided the string representation of the filter object (e.g., org.springframework.cloud.gateway.filter.LoadBalancerClientFilter@77856cc5) and the corresponding order in the filter chain.

11.1.2 Route Filters

To retrieve the GatewayFilter factories applied to routes, make a GET request to /actuator/gateway/routefilters. The resulting response is similar to the following:

{
+  "[AddRequestHeaderGatewayFilterFactory@570ed9c configClass = AbstractNameValueGatewayFilterFactory.NameValueConfig]": null,
+  "[SecureHeadersGatewayFilterFactory@fceab5d configClass = Object]": null,
+  "[SaveSessionGatewayFilterFactory@4449b273 configClass = Object]": null
+}

The response contains details of the GatewayFilter factories applied to any particular route. For each factory is provided the string representation of the corresponding object (e.g., [SecureHeadersGatewayFilterFactory@fceab5d configClass = Object]). Note that the null value is due to an incomplete implementation of the endpoint controller, for that it tries to set the order of the object in the filter chain, which does not apply to a GatewayFilter factory object.

11.2 Refreshing the route cache

To clear the routes cache, make a POST request to /actuator/gateway/refresh. The request returns a 200 without response body.

11.3 Retrieving the routes defined in the gateway

To retrieve the routes defined in the gateway, make a GET request to /actuator/gateway/routes. The resulting response is similar to the following:

[{
+  "route_id": "first_route",
+  "route_object": {
+    "predicate": "org.springframework.cloud.gateway.handler.predicate.PathRoutePredicateFactory$$Lambda$432/1736826640@1e9d7e7d",
+    "filters": [
+      "OrderedGatewayFilter{delegate=org.springframework.cloud.gateway.filter.factory.PreserveHostHeaderGatewayFilterFactory$$Lambda$436/674480275@6631ef72, order=0}"
+    ]
+  },
+  "order": 0
+},
+{
+  "route_id": "second_route",
+  "route_object": {
+    "predicate": "org.springframework.cloud.gateway.handler.predicate.PathRoutePredicateFactory$$Lambda$432/1736826640@cd8d298",
+    "filters": []
+  },
+  "order": 0
+}]

The response contains details of all the routes defined in the gateway. The following table describes the structure of each element (i.e., a route) of the response.

PathTypeDescription

route_id

String

The route id.

route_object.predicate

Object

The route predicate.

route_object.filters

Array

The GatewayFilter factories applied to the route.

order

Number

The route order.

11.4 Retrieving information about a particular route

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:

{
+  "id": "first_route",
+  "predicates": [{
+    "name": "Path",
+    "args": {"_genkey_0":"/first"}
+  }],
+  "filters": [],
+  "uri": "http://www.uri-destination.org",
+  "order": 0
+}]

The following table describes the structure of the response.

PathTypeDescription

id

String

The route id.

predicates

Array

The collection of route predicates. Each item defines the name and the arguments of a given predicate.

filters

Array

The collection of filters applied to the route.

uri

String

The destination URI of the route.

order

Number

The route order.

11.5 Creating and deleting a particular route

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

To delete a route, make a DELETE request to /gateway/routes/{id_route_to_delete}.

11.6 Recap: list of all endpoints

The table below summarises the Spring Cloud Gateway actuator endpoints. Note that each endpoint has /actuator/gateway as the base-path.

IDHTTP MethodDescription

globalfilters

GET

Displays the list of global filters applied to the routes.

routefilters

GET

Displays the list of GatewayFilter factories applied to a particular route.

refresh

POST

Clears the routes cache.

routes

GET

Displays the list of routes defined in the gateway.

routes/{id}

GET

Displays information about a particular route.

routes/{id}

POST

Add a new route to the gateway.

routes/{id}

DELETE

Remove an existing route from the gateway.

12. Developer Guide

TODO: overview of writing custom integrations

12.1 Writing Custom Route Predicate Factories

TODO: document writing Custom Route Predicate Factories

12.2 Writing Custom GatewayFilter Factories

In order to write a GatewayFilter you will need to implement GatewayFilterFactory. There is an abstract class called AbstractGatewayFilterFactory which you can extend.

PreGatewayFilterFactory.java. 

public class PreGatewayFilterFactory extends AbstractGatewayFilterFactory<PreGatewayFilterFactory.Config> {
 
 	public PreGatewayFilterFactory() {
diff --git a/spring-cloud-gateway.xml b/spring-cloud-gateway.xml
index 9a942e67..7be0092d 100644
--- a/spring-cloud-gateway.xml
+++ b/spring-cloud-gateway.xml
@@ -1287,7 +1287,221 @@ public RouteLocator customRouteLocator(RouteLocatorBuilder builder, ThrottleGate
 
 
 Actuator API
-TODO: document the /gateway actuator endpoint
+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.
+
+application.properties
+
+management.endpoint.gateway.enabled=true # default value
+management.endpoints.web.exposure.include=gateway
+
+
+
+Retrieving route filters +
+Global Filters +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: +{ + "org.springframework.cloud.gateway.filter.LoadBalancerClientFilter@77856cc5": 10100, + "org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter@4f6fd101": 10000, + "org.springframework.cloud.gateway.filter.NettyWriteResponseFilter@32d22650": -1, + "org.springframework.cloud.gateway.filter.ForwardRoutingFilter@106459d9": 2147483647, + "org.springframework.cloud.gateway.filter.NettyRoutingFilter@1fbd5e0": 2147483647, + "org.springframework.cloud.gateway.filter.ForwardPathFilter@33a71d23": 0, + "org.springframework.cloud.gateway.filter.AdaptCachedBodyGlobalFilter@135064ea": 2147483637, + "org.springframework.cloud.gateway.filter.WebsocketRoutingFilter@23c05889": 2147483646 +} +The response contains details of the global filters in place. For each global filter is provided the string representation of the filter object (e.g., org.springframework.cloud.gateway.filter.LoadBalancerClientFilter@77856cc5) and the corresponding order in the filter chain. +
+
+Route Filters +To retrieve the GatewayFilter factories applied to routes, make a GET request to /actuator/gateway/routefilters. The resulting response is similar to the following: +{ + "[AddRequestHeaderGatewayFilterFactory@570ed9c configClass = AbstractNameValueGatewayFilterFactory.NameValueConfig]": null, + "[SecureHeadersGatewayFilterFactory@fceab5d configClass = Object]": null, + "[SaveSessionGatewayFilterFactory@4449b273 configClass = Object]": null +} +The response contains details of the GatewayFilter factories applied to any particular route. For each factory is provided the string representation of the corresponding object (e.g., [SecureHeadersGatewayFilterFactory@fceab5d configClass = Object]). Note that the null value is due to an incomplete implementation of the endpoint controller, for that it tries to set the order of the object in the filter chain, which does not apply to a GatewayFilter factory object. +
+
+
+Refreshing the route cache +To clear the routes cache, make a POST request to /actuator/gateway/refresh. The request returns a 200 without response body. +
+
+Retrieving the routes defined in the gateway +To retrieve the routes defined in the gateway, make a GET request to /actuator/gateway/routes. The resulting response is similar to the following: +[{ + "route_id": "first_route", + "route_object": { + "predicate": "org.springframework.cloud.gateway.handler.predicate.PathRoutePredicateFactory$$Lambda$432/1736826640@1e9d7e7d", + "filters": [ + "OrderedGatewayFilter{delegate=org.springframework.cloud.gateway.filter.factory.PreserveHostHeaderGatewayFilterFactory$$Lambda$436/674480275@6631ef72, order=0}" + ] + }, + "order": 0 +}, +{ + "route_id": "second_route", + "route_object": { + "predicate": "org.springframework.cloud.gateway.handler.predicate.PathRoutePredicateFactory$$Lambda$432/1736826640@cd8d298", + "filters": [] + }, + "order": 0 +}] +The response contains details of all the routes defined in the gateway. The following table describes the structure of each element (i.e., a route) of the response. + + + + + + + +Path +Type +Description + + + + +route_id +String +The route id. + + +route_object.predicate +Object +The route predicate. + + +route_object.filters +Array +The GatewayFilter factories applied to the route. + + +order +Number +The route order. + + + + +
+
+Retrieving information about a particular route +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: +{ + "id": "first_route", + "predicates": [{ + "name": "Path", + "args": {"_genkey_0":"/first"} + }], + "filters": [], + "uri": "http://www.uri-destination.org", + "order": 0 +}] +The following table describes the structure of the response. + + + + + + + +Path +Type +Description + + + + +id +String +The route id. + + +predicates +Array +The collection of route predicates. Each item defines the name and the arguments of a given predicate. + + +filters +Array +The collection of filters applied to the route. + + +uri +String +The destination URI of the route. + + +order +Number +The route order. + + + + +
+
+Creating and deleting a particular route +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). +To delete a route, make a DELETE request to /gateway/routes/{id_route_to_delete}. +
+
+Recap: list of all endpoints +The table below summarises the Spring Cloud Gateway actuator endpoints. Note that each endpoint has /actuator/gateway as the base-path. + + + + + + + +ID +HTTP Method +Description + + + + +globalfilters +GET +Displays the list of global filters applied to the routes. + + +routefilters +GET +Displays the list of GatewayFilter factories applied to a particular route. + + +refresh +POST +Clears the routes cache. + + +routes +GET +Displays the list of routes defined in the gateway. + + +routes/{id} +GET +Displays information about a particular route. + + +routes/{id} +POST +Add a new route to the gateway. + + +routes/{id} +DELETE +Remove an existing route from the gateway. + + + + +
Developer Guide