Spring Cloud Gateway中read-body的配置是做什么用的?

新手上路,请多包涵

今天学习了一下目前所在项目的网关是怎么实现的,使用的Spring Cloud Gateway
发现配置文件中有一个配置是:

spring:
 cloud:
    gateway:
      predicate:
        read-body:
          enabled: true

查看了Spring的官网文档,没找到太有用处的描述,只看到了一句:
image.png
一开始以为是对ReadBodyPredicateFactory的使用,但此断言工厂本就有使用的方式:

predicates:
   - Path=/**
   - name: ReadBodyPredicateFactory

自己编写demo尝试使用read-body时,还会有提示信息:Cannot resolve configuration property 'spring.cloud.gateway.predicate.read-body.enabled'
所以read-body到底是用来做什么的呢

阅读 1.9k
1 个回答
spring:
  cloud:
    gateway:
      routes:
      - id: read_body_route
        uri: http://example.org
        predicates:
        - Path=/testpath
        - ReadBody=String, \
          @io.projectr.ReadBodyPredicateFactoryTests.ReqObjCheckForPostReq
        filters:
        - ModifyRequestBody= String, String, \
            @io.projectr.gateway.filter.factory.rewrite.ModifyRequestBodyGatewayFilterFactoryTests.ToString
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题