Experimental shouldReturnHtml
2 files changed, 11 insertions(+), 0 deletions(-)

M build.gradle
M src/org/overchat/overham/Server.java
M build.gradle +1 -0
@@ 82,6 82,7 @@ dependencies {
 	runtime group: 'org.reflections', name: 'reflections', version:'0.9.11'
 	runtime group: 'com.google.guava', name: 'guava', version:'21.0'
 	runtime group: 'mysql', name: 'mysql-connector-java', version:'5.1.18'
+	runtime group: 'com.j2html', name: 'j2html', version:'1.2.0'
 
 	// Use JUnit test framework
 	testImplementation 'junit:junit:4.12'

          
M src/org/overchat/overham/Server.java +10 -0
@@ 61,6 61,8 @@ import com.amazonaws.services.s3.AmazonS
 import com.google.common.io.Files;
 import com.google.common.io.Resources;
 
+import spark.Request;
+
 /**
  * @author duncan.palmer
  *

          
@@ 179,6 181,11 @@ public class Server {
 		return sb.toString();
 	}
 
+	private static boolean shouldReturnHtml(Request request) {
+		String accept = request.headers("Accept");
+		return accept != null && accept.contains("text/html");
+	}
+
 	@SuppressWarnings("deprecation")
 	public void init() {
 		List<String> modules = this.modules();

          
@@ 192,6 199,9 @@ public class Server {
 				java.lang.System.out.println("Created route path: " + routePath + " (" + methodMimeType + ")");
 
 				get(routePath, (req, res) -> { // This Lambda requires Java 1.8
+					if (shouldReturnHtml(req)) {
+					}
+
 					Map<String, String> requestParams = new HashMap<String, String>();
 					Set<String> argNames = req.queryParams();
 					for (String argName : argNames) {