目录
查看 Zuul 的路由端点和过滤器信息
当 @EnableZuulProxy
与 Spring Boot Actuator 配合使用时,Zuul 会暴露一个路由管理端点 /routes
和一个过滤器端点 /filters
。借助这两个端点,可以方便、直观地查看以及管理 Zuul 的路由和过滤器信息。
首先在 blog-zuul-gateway 的 pom.xml
里添加依赖:
<!-- spring actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
然后将所有端点都暴露出来,在 application.yml
配置文件中增加以下配置:
management:
endpoints:
web:
exposure:
include: '*'
访问 http://localhost:8001/actuator/routes 可以显示所有路由信息:
访问 http://localhost:8001/actuator/filters 可以显示所有过滤器信息: