+package de.juplo.demo;
+
+import org.springframework.web.reactive.function.client.WebClient;
+import reactor.core.publisher.Mono;
+
+
+/**
+ * Fetches data from remote-webserver.
+ * @author Kai Moritz
+ */
+public class RemoteContentService
+{
+ WebClient webClient;
+
+
+ /**
+ * The {@link WebClient}, that is used to fetch the data.
+ * <p>
+ * The <code>WebClient</code> has to be configured to us a given
+ * remote-server by default. This service will only add a path.
+ * @param webClient a <code>WebClient</code> instance with configured host
+ */
+ public RemoteContentService(WebClient webClient)
+ {
+ this.webClient = webClient;
+ }
+
+
+ /**
+ * Fetches the given path from the configured remote-server.
+ * @param path the path to fetch from the configured remote-server
+ * @return a {@link Mono}, that represents the fetched data
+ */
+ public Mono<String> getRemoteText(String path)
+ {
+ return
+ webClient
+ .get()
+ .uri(path)
+ .retrieve()
+ .bodyToMono(String.class);
+ }
+}