admin 管理员组文章数量: 887021
2024年2月18日发(作者:数据库系统概论读写说)
import serter;import serters;import rStrategies;import Request;import WebExchange;import ;import ;
import ;import Reference;import tion;
/** * @author chenws * @date 2019/12/12 09:33:53 */@Componentpublic class CModifyRequestBodyGatewayFilterFactory extends AbstractGatewayFilterFactory {
private final List
public CModifyRequestBodyGatewayFilterFactory() { eReaders = faults().messageReaders(); }
@Override @SuppressWarnings("unchecked") public GatewayFilter apply(Object config) { return (exchange, chain) -> { ServerRequest serverRequest = (exchange, eReaders);
Mono
BodyInserter bodyInserter = blisher(modifiedBody, ); HttpHeaders headers = new HttpHeaders(); (uest().getHeaders()); (T_LENGTH);
CachedBodyOutputMessage outputMessage = new CachedBodyOutputMessage(exchange, headers); return (outputMessage, new BodyInserterContext()) .then((() -> { ServerHttpRequest decorator = decorate(exchange, headers, outputMessage); return (().request(decorator).build()); }));
}; }
/** * 修改body * @return apply 返回Mono
private ServerHttpRequestDecorator decorate(ServerWebExchange exchange, HttpHeaders headers, CachedBodyOutputMessage outputMessage) { return new ServerHttpRequestDecorator(uest()) { @Override public HttpHeaders getHeaders() { long contentLength = tentLength();
版权声明:本文标题:SpringCloudgatewayrequest的body验证或修改方式 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1708216284h516992.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论