Spring Cloud Gateway 数据库存储路由信息的扩展方案
动态路由背景
无论你在使用Zuul还是Spring Cloud Gateway 的时候,官方文档提供的方案总是基于配置文件配置的方式
例如:
# zuul 的配置形式
routes:
pig-auth:
path: /auth/**
serviceId: pig-auth
stripPrefix: true
# gateway 的配置形式
routes:
- id: pigx-auth
uri: lb://pigx-auth
predicates:
- Path=/auth/**
filters:
- ValidateCodeGatewayFilter
配置更改需要重启服务,不能满足实际生产过程中的动态刷新、实时变更的业