+
+ public Mono<ResponseEntity<String>> putForEntity(String uri) {
+ logger.debug("PUT uri = '{}{}''", baseUrl, uri);
+ RequestHeadersSpec<?> request = client.put() //
+ .uri(uri);
+ return retrieve(request);
+ }
+
+ public Mono<String> put(String uri, String body) {
+ return putForEntity(uri, body) //
+ .flatMap(this::toBody);
+ }
+
+ public Mono<ResponseEntity<String>> getForEntity(String uri) {
+ logger.debug("GET uri = '{}{}''", baseUrl, uri);
+ RequestHeadersSpec<?> request = client.get().uri(uri);
+ return retrieve(request);
+ }
+
+ public Mono<String> get(String uri) {
+ return getForEntity(uri) //
+ .flatMap(this::toBody);
+ }
+
+ public Mono<ResponseEntity<String>> deleteForEntity(String uri) {
+ logger.debug("DELETE uri = '{}{}''", baseUrl, uri);
+ RequestHeadersSpec<?> request = client.delete().uri(uri);
+ return retrieve(request);
+ }
+
+ public Mono<String> delete(String uri) {
+ return deleteForEntity(uri) //
+ .flatMap(this::toBody);
+ }
+
+ private Mono<ResponseEntity<String>> retrieve(RequestHeadersSpec<?> request) {
+ return request.retrieve() //
+ .toEntity(String.class) //
+ .doOnError(this::onHttpError);
+ }
+
+ private void onHttpError(Throwable t) {
+ if (t instanceof WebClientResponseException) {
+ WebClientResponseException exception = (WebClientResponseException) t;
+ logger.debug("HTTP error status = '{}', body '{}'", exception.getStatusCode(),
+ exception.getResponseBodyAsString());
+ } else {
+ logger.debug("HTTP error: {}", t.getMessage());
+ }
+ }
+
+ private Mono<String> toBody(ResponseEntity<String> entity) {
+ if (entity.getBody() == null) {
+ return Mono.just("");
+ } else {
+ return Mono.just(entity.getBody());
+ }
+ }
+