WIP deface
authorKai Moritz <kai@juplo.de>
Sat, 9 Jan 2021 08:29:21 +0000 (09:29 +0100)
committerKai Moritz <kai@juplo.de>
Sat, 9 Jan 2021 08:29:21 +0000 (09:29 +0100)
src/main/java/de/juplo/demo/httpresources/DefaceController.java [new file with mode: 0644]
src/main/java/de/juplo/demo/httpresources/DemoController.java [deleted file]
src/main/resources/overwrite/help.html [new file with mode: 0644]

diff --git a/src/main/java/de/juplo/demo/httpresources/DefaceController.java b/src/main/java/de/juplo/demo/httpresources/DefaceController.java
new file mode 100644 (file)
index 0000000..5c30031
--- /dev/null
@@ -0,0 +1,25 @@
+package de.juplo.demo.httpresources;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+
+@Controller
+public class DefaceController
+{
+  @RequestMapping("/{path}.html")
+  public String controller(
+      @PathVariable String path,
+      @RequestParam(required = false) String origin,
+      Model model)
+  {
+    if (origin == null)
+      return "redirect:/help.html";
+
+    model.addAttribute("template", origin);
+    return path;
+  }
+}
diff --git a/src/main/java/de/juplo/demo/httpresources/DemoController.java b/src/main/java/de/juplo/demo/httpresources/DemoController.java
deleted file mode 100644 (file)
index 96020ff..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-package de.juplo.demo.httpresources;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-
-
-@Controller
-public class DemoController
-{
-  @RequestMapping("/controller.html")
-  public String controller(
-      @RequestParam(defaultValue = "index") String template,
-      Model model)
-  {
-    model.addAttribute("template", template);
-    return template;
-  }
-}
diff --git a/src/main/resources/overwrite/help.html b/src/main/resources/overwrite/help.html
new file mode 100644 (file)
index 0000000..155fe48
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Help</title>
+  </head>
+  <body>
+    <h1>Help</h1>
+    <formgroup>
+      Start any webserver at <strong>http://localhost:8888</strong> or
+      overwrite <strong>origin</strong> in the
+      <strong>application.properties</strong>...
+    </formgroup>
+  </body>
+</html>