【11】网关管理API
文章目录
-
- 前言
- 管理API
-
-
- 查询所有路由
-
- 查询过滤器
-
- 刷新路由缓存
-
- 查询单个路由信息
-
- 创建和删除路由
-
前言
Spring Cloud Gateway 提供了很多API 用来管理网关,在org.springframework.cloud.gateway.actuate包中,可以看到提供了一些访问API。

管理API
需要配置spring-boot-starter-actuator,公开这些访问端点,首先添加Pom:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
然后在YML中公开这些端点:
management:
endpoint:
health:
# 是否显示health详细信息
show-details: always
show-components: always
gateway:
enabled: true
endpoints:
# Web端点的配置属性
web:
exposure:
# 开放端点的ID集合(eg:['health','info','beans','env']),配置为“*”表示全部
include: '*'
1. 查询所有路由
可以通过 GET /actuator/gateway/routes查询到所有路由信息:
https://localhost:8443/actuator/gateway/routes