Separated layout from content with Thymeleaf
[demos/testing] / src / main / java / de / juplo / demo / HtmlController.java
1 package de.juplo.demo;
2
3
4 import org.springframework.stereotype.Controller;
5 import org.springframework.ui.Model;
6 import org.springframework.web.bind.annotation.GetMapping;
7 import org.springframework.web.bind.annotation.RequestParam;
8
9
10 /**
11  * Fetches data from a remote-webserver and renders it as HTML.
12  * @author Kai Moritz
13  */
14 @Controller
15 public class HtmlController
16 {
17   RemoteContentService service;
18
19
20   public HtmlController(RemoteContentService service)
21   {
22     this.service = service;
23   }
24
25
26   @GetMapping("/")
27   public String fetch(Model model, @RequestParam String path)
28   {
29     model.addAttribute("text", service.getRemoteText(path));
30     return "home";
31   }
32 }