I am new to spring webclient and i have written a generic method which can be used to consume rest apis in my application:
public <T> List<T> get(URI url, Class<T> responseType) {
return WebClient.builder().build().get().uri(url)
.header("Authorization", "Basic " + principal)
.retrieve().bodyToFlux(responseType).collectList().block();
}
i wanted to return and empty list if consumed rest-api return 404.
can someone suggest how to achieve that?