我正在注册过滤器来记录来自webclient的响应,但是我只想记录post和patch请求(没有太多我不感兴趣的get请求)。如何只记录特定的post和patch响应?
webclient bean:
@Bean
public WebClient sfWebClient() {
return WebClient.builder()
.filter(logResponse())
.build();
}
logresponse筛选器:
ExchangeFilterFunction logResponse() {
return ExchangeFilterFunction.ofResponseProcessor(clientResponse -> {
if (log.isDebugEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Request finished with the status: ").append(clientResponse.statusCode());
log.debug(sb.toString());
}
return Mono.just(clientResponse);
});
}
1条答案
按热度按时间lmvvr0a81#
我认为您可以像这样实现自己的ExchangeFilter功能: