Added a rest-controller, that serves the fetched data as text/plain
[demos/testing] / src / main / java / de / juplo / demo / RestController.java
diff --git a/src/main/java/de/juplo/demo/RestController.java b/src/main/java/de/juplo/demo/RestController.java
new file mode 100644 (file)
index 0000000..b32f796
--- /dev/null
@@ -0,0 +1,31 @@
+package de.juplo.demo;
+
+
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import reactor.core.publisher.Mono;
+
+
+/**
+ * Fetches and returns data from a remote-webserver.
+ * @author Kai Moritz
+ */
+@org.springframework.web.bind.annotation.RestController
+public class RestController
+{
+  RemoteContentService service;
+
+
+  public RestController(RemoteContentService service)
+  {
+    this.service = service;
+  }
+
+
+  @GetMapping(path = "/", produces = MediaType.TEXT_PLAIN_VALUE)
+  public Mono<String> fetch(@RequestParam String path)
+  {
+    return service.getRemoteText(path);
+  }
+}