spring-云网关路径路由谓词不接受“/”

spring-cloud-gateway path route predicate don't accept "/"

我有一个使用 application.yml 中编写的路由的自定义网关过滤器, 当我想将路由谓词从 /test/myTest 更改为 /public 请求 return 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

这是我得到的错误:

No content

< 404 NOT_FOUND Not Found < Content-Type: [application/json] < Content-Length: [147]

{"timestamp":"2020-08-26T15:44:12.023+0000","path":"/test/myTest/whatever","status":404,"error":"Not Found","message":null,"requestId":"e7baeeeb-6"}

java.lang.AssertionError: Status expected:<200 OK> but was:<404 NOT_FOUND>

来自documentation :

spring:
  cloud:
    gateway:
      routes:
      - id: nameRoot
        uri: https://nameservice
        predicates:
        - Path=/name/**
        filters:
        - StripPrefix=2

当通过网关向 /name/blue/red 发出请求时,向 nameservice 发出的请求看起来像 nameservice/red

你应该把 1 改成 2。