package de.juplo.demo;
-
-<<<<<<< HEAD:src/main/java/de/juplo/demo/RemoteContentController.java
-=======
->>>>>>> f9152f7... WIP: Implemented...:src/main/java/de/juplo/integrationtest/RemoteContentController.java
-import org.springframework.ui.Model;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.reactive.function.client.WebClient;
+import org.springframework.web.bind.annotation.RestController;
+import reactor.core.publisher.Mono;
/**
* Fetches data from remote-webserver and renders them as HTML.
* @author Kai Moritz
*/
+@RestController
public class RemoteContentController
{
- WebClient webClient;
-
-
- public RemoteContentController(WebClient webClient)
- {
- this.webClient = webClient;
- }
+ @Autowired
+ RemoteContentService service;
@GetMapping("/")
- public String renderRemoteText(Model model, @RequestParam String path)
+ public Mono<String> renderRemoteText(@RequestParam String path)
{
- model.addAttribute(
- "text",
- webClient
- .get()
- .uri(path)
- .retrieve()
- .bodyToMono(String.class).block());
-
- return "layout";
+ return service.getRemoteText(path);
}
}