如何在 spring 网关过滤器配置中注入变量占位符 `${}`?

How to inject a variable placeholder `${}` in the spring gateway filters configuration?

如何在 spring 网关过滤器配置中注入变量占位符 ${}

foo:
  bar: 
    uri: /coucou

spring:
  cloud:
    gateway:
      routes:
      - id: prefixpath_route
        uri: https://example.org
        filters:
        - PrefixPath=$\{foo.bar.uri}

注意:

正如@spencergibb 强调的那样,它通过使用 args 子属性来工作:

   filters:
    - name: PrefixPath
      args:
        prefix: ${foo.bar.uri}

参见 gist.github。com/spencergibb/873f239529f79cb784d4eab3a9ddc4a6