【发布时间】:2020-12-15 12:13:34
【问题描述】:
我有一个自定义网关过滤器,它使用 application.yml 中编写的路由, 当我想将路由谓词从 /test/myTest 更改为 /public 时,请求返回 404 似乎就像“/”没有重新调整,因为我试图将 /test-myTest 更改为 /public 并且它的工作。
请知道如何使用这种格式的谓词 /name/name/**
这是我的 application.yml :
myTest-gateway:
default-uri: https://app
apps:
/test/myTest: mymicroservice-name
spring:
cloud:
gateway:
enabled: false
x-forwarded:
proto-enabled: false
routes:
- id: appsPrefixPathPublic
uri: ${myTest-gateway.default-uri}
predicates:
- AppPath=/test/myTest
filters:
- StripPrefix=1
- PrefixPath=/public
这是我得到的错误:
没有内容
{"timestamp":"2020-08-26T15:44:12.023+0000","path":"/test/myTest/whatever","status":404,"error":"不是 找到","message":null,"requestId":"e7baeeeb-6"}
java.lang.AssertionError:预期状态: 但原为:
【问题讨论】:
-
请注意,您应该使用反引号保护 URL;看来您的问题可能没有正确显示。
标签: java spring-boot spring-cloud-config spring-cloud-gateway