Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Gorzala committed Dec 15, 2023
1 parent 32fb206 commit a9e6d99
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public class ChatServiceClient {
public void init() {
this.webClient = WebClient.builder()
.baseUrl(host)
.filters(filtersConsumer -> {
filtersConsumer.add(buildRetryExchangeFilterFunction());
filtersConsumer.add(logRequest());
})
.filter(buildRetryExchangeFilterFunction())
.build();
}
Expand Down Expand Up @@ -109,4 +113,20 @@ private ExchangeFilterFunction buildRetryExchangeFilterFunction() {
.retryWhen(Retry.backoff(3, Duration.ofMillis(500)));
}

private ExchangeFilterFunction logRequest() {
return ExchangeFilterFunction.ofRequestProcessor(clientRequest -> {
if (log.isDebugEnabled()) {
StringBuilder sb = new StringBuilder("Request: \n");
//append clientRequest method and url
clientRequest
.headers()
.forEach((name, values) -> values.forEach(value -> sb.append(value)/* append header key/value */));
log.info(sb.toString());
}
return Mono.just(clientRequest);
});
}


}

0 comments on commit a9e6d99

Please sign in to comment.