我想从 zuul 迁移到 spring 云网关,我不想更改我以前的应用程序的配置。我想知道如何处理带有“/api/ + 'serviceId'”的 url,路由到 lb://serviceId
之前的 zuul 配置
zuul:
prefix: /api
Run Code Online (Sandbox Code Playgroud)
eureka 有很多服务注册,我不想为每个服务注册一个路由。
例如。由 org.springframework.cloud.gateway.discovery.DiscoveryClientRouteDefinitionLocator 自动生成的路由
{
"route_id": "CompositeDiscoveryClient_APIGATEWAY",
"route_definition": {
"id": "CompositeDiscoveryClient_APIGATEWAY",
"predicates": [
{
"name": "Path",
"args": {
"pattern": "/apigateway/**"
}
}
],
"filters": [
{
"name": "RewritePath",
"args": {
"regexp": "/apigateway/(?<remaining>.*)",
"replacement": "/${remaining}"
}
}
],
"uri": "lb://APIGATEWAY",
"order": 0
}
Run Code Online (Sandbox Code Playgroud)
我想要的是
{
"route_id": "CompositeDiscoveryClient_APIGATEWAY",
"route_definition": {
"id": "CompositeDiscoveryClient_APIGATEWAY",
"predicates": [
{
"name": "Path",
"args": {
"pattern": "/api/apigateway/**"
}
}
],
"filters": [ …Run Code Online (Sandbox Code Playgroud)