For a sample route definition below, when the control goes to MyCustomFilter
, Is there any way to get the following information
Route Definition:
- id: test-route
uri: http://my-downstream-service.com
predicates:
- Path=/v3/status
- Method=POST
filters:
- MyCustomFilter
All the matched route information like id, URI, predicates & filters are available in org.springframework.cloud.gateway.route.Route
, all we need to do is to get the handle of the Route object using the below statement in any of the filters.
org.springframework.cloud.gateway.route.Route route = exchange.getAttribute(org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR);
and get the required information like route.getId()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With