要启用gateway的Actuator交互首先添加依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
其次在application.properties配置:
management.endpoint.gateway.enabled=true
management.endpoints.web.exposure.include=gateway
/actuator/gateway/routes
查看gateway的所有routes及predicate,Filter。访问http://localhost:8500/actuator/gateway/routes:
[{
"predicate": "Paths: [/producer/{segment}], match trailing slash: true",
"route_id": "Goods-Server",
"filters": ["[[StripPrefix parts = 1], order = 1]"],
"uri": "lb://producer",
"order": 0
}]
/actuator/gateway/globalfilters
查看所有的全局过滤器。访问http://localhost:8500/actuator/gateway/globalfilters:
{
"org.springframework.cloud.gateway.filter.NettyWriteResponseFilter@2bb62414": -1,
"org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter@7243145f": 10150,
"org.springframework.cloud.gateway.filter.LoadBalancerServiceInstanceCookieFilter@15c6027d": 10151,
"org.springframework.cloud.gateway.filter.WebsocketRoutingFilter@30bbcf91": 2147483646,
"org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter@644d1b61": 10000,
"org.springframework.cloud.gateway.filter.NettyRoutingFilter@5927f904": 2147483647,
"org.springframework.cloud.gateway.filter.AdaptCachedBodyGlobalFilter@315c081": -2147482648,
"org.springframework.cloud.gateway.filter.GatewayMetricsFilter@3ca14cf4": 0,
"org.springframework.cloud.gateway.filter.ForwardPathFilter@184823ed": 0,
"org.springframework.cloud.gateway.filter.ForwardRoutingFilter@2443135": 2147483647,
"com.example.filter.CustomGlobalFilter@b0f2d91": -1,
"org.springframework.cloud.gateway.filter.RemoveCachedBodyFilter@413d2cd1": -2147483648
}
后面的数字表示Order值。
/actuator/gateway/routefilters
查看所有的gatewayFilter。访问http://localhost:8500/actuator/gateway/routefilters:
{
"[AddRequestHeaderGatewayFilterFactory@7ddcb0dc configClass = AbstractNameValueGatewayFilterFactory.NameValueConfig]": null,
"[DedupeResponseHeaderGatewayFilterFactory@6e9a0bea configClass = DedupeResponseHeaderGatewayFilterFactory.Config]": null,
"[StripPrefixGatewayFilterFactory@4be490da configClass = StripPrefixGatewayFilterFactory.Config]": null,
"[RequestHeaderToRequestUriGatewayFilterFactory@4168f3d9 configClass = AbstractGatewayFilterFactory.NameConfig]": null,
"[SaveSessionGatewayFilterFactory@2aa14ae6 configClass = Object]": null,
"[RedirectToGatewayFilterFactory@560271a1 configClass = RedirectToGatewayFilterFactory.Config]": null,
"[SecureHeadersGatewayFilterFactory@5287ba5f configClass = SecureHeadersGatewayFilterFactory.Config]": null,
"[AddResponseHeaderGatewayFilterFactory@26c77f54 configClass = AbstractNameValueGatewayFilterFactory.NameValueConfig]": null,
"[RemoveRequestParameterGatewayFilterFactory@41e9f86 configClass = AbstractGatewayFilterFactory.NameConfig]": null,
"[SetRequestHostHeaderGatewayFilterFactory@6897a4a configClass = SetRequestHostHeaderGatewayFilterFactory.Config]": null,
"[ModifyResponseBodyGatewayFilterFactory@28fc1132 configClass = ModifyResponseBodyGatewayFilterFactory.Config]": null,
"[RemoveRequestHeaderGatewayFilterFactory@4b9c411 configClass = AbstractGatewayFilterFactory.NameConfig]": null,
"[PreserveHostHeaderGatewayFilterFactory@1e3f86d5 configClass = Object]": null,
"[ModifyRequestBodyGatewayFilterFactory@3e856100 configClass = ModifyRequestBodyGatewayFilterFactory.Config]": null,
"[FallbackHeadersGatewayFilterFactory@7c950b3b configClass = FallbackHeadersGatewayFilterFactory.Config]": null,
"[RewriteResponseHeaderGatewayFilterFactory@6bce313 configClass = RewriteResponseHeaderGatewayFilterFactory.Config]": null,
"[SetResponseHeaderGatewayFilterFactory@6986f93e configClass = AbstractNameValueGatewayFilterFactory.NameValueConfig]": null,
"[SetStatusGatewayFilterFactory@74b00247 configClass = SetStatusGatewayFilterFactory.Config]": null,
"[PrefixPathGatewayFilterFactory@20440c6c configClass = PrefixPathGatewayFilterFactory.Config]": null,
"[RewritePathGatewayFilterFactory@233f52f8 configClass = RewritePathGatewayFilterFactory.Config]": null,
"[SetRequestHeaderGatewayFilterFactory@b768a65 configClass = AbstractNameValueGatewayFilterFactory.NameValueConfig]": null,
"[RequestSizeGatewayFilterFactory@353e6389 configClass = RequestSizeGatewayFilterFactory.RequestSizeConfig]": null,
"[RequestHeaderSizeGatewayFilterFactory@15e8f9b2 configClass = RequestHeaderSizeGatewayFilterFactory.Config]": null,
"[SpringCloudCircuitBreakerResilience4JFilterFactory@7a65c995 configClass = SpringCloudCircuitBreakerFilterFactory.Config]": null,
"[RemoveResponseHeaderGatewayFilterFactory@66f5b8fe configClass = AbstractGatewayFilterFactory.NameConfig]": null,
"[CacheRequestBodyGatewayFilterFactory@355ce6a6 configClass = CacheRequestBodyGatewayFilterFactory.Config]": null,
"[MapRequestHeaderGatewayFilterFactory@f5bf288 configClass = MapRequestHeaderGatewayFilterFactory.Config]": null,
"[RewriteLocationResponseHeaderGatewayFilterFactory@39266403 configClass = RewriteLocationResponseHeaderGatewayFilterFactory.Config]": null,
"[SetPathGatewayFilterFactory@19fec3d6 configClass = SetPathGatewayFilterFactory.Config]": null,
"[AddRequestParameterGatewayFilterFactory@2c1d57bc configClass = AbstractNameValueGatewayFilterFactory.NameValueConfig]": null,
"[RetryGatewayFilterFactory@69ec93c2 configClass = RetryGatewayFilterFactory.RetryConfig]": null
}
后面的null是Order值。
/actuator/gateway/refresh
以POST方式刷新路由缓存。
/actuator/gateway/routes/
get方式:查看特定路由id的信息。访问http://localhost:8500/actuator/gateway/routes/Goods-Server:
{
"predicate": "Paths: [/producer/{segment}], match trailing slash: true",
"route_id": "Goods-Server",
"filters": ["[[StripPrefix parts = 1], order = 1]"],
"uri": "lb://producer",
"order": 0
}
post方式:创建指定路由id的路由。要创建的路由信息以JSON格式放入请求体。
delete方式:删除指定路由id的路由。
标签:configClass,SpringCloud,springframework,org,Actuator,null,Config,gateway From: https://www.cnblogs.com/shigongp/p/17379235.html