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

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

spring:

cloud:

gateway:

predicate:

read-body:

enabled: true

查看了Spring的官网文档,没找到太有用处的描述,只看到了一句:

一开始以为是对ReadBodyPredicateFactory的使用,但此断言工厂本就有使用的方式:

predicates:

- Path=/**

- name: ReadBodyPredicateFactory

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


回答:

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

以上是 Spring Cloud Gateway中read-body的配置是做什么用的? 的全部内容, 来源链接: utcz.com/p/945174.html

回到顶部