我目前正尝试从RestTemplate转移,因为它已被剥离到Spring WebClient。目前,我对如何记录响应和执行时间的方法感到困惑。
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution){
long startTime = System.currentTimeMillis();
try {
ClientHttpResponse clientHttpResponse = execution.execute(request, body);
if (outboundMetrics != null) {
int httpStatusCode = clientHttpResponse.getRawStatusCode();
HttpOutboundMetrics.ResponseStatus responseStatus = null;
if (httpStatusCode >= 200 && httpStatusCode < 300) {
responseStatus = HttpOutboundMetrics.ResponseStatus.HTTP_2XX_RESPONSE;
}
outboundMetrics.recordCallStatus(responseStatus, startTime, System.currentTimeMillis());
}
return clientHttpResponse;
}
我对Rest Template Intercept的原始代码是什么。 webclient筛选器是否具有与execute.execute等效的内容?