From b7c8134eeec10eb0269b166e6bbbd5a6cfd2d716 Mon Sep 17 00:00:00 2001 From: Alan Richardson Date: Sat, 23 Mar 2024 13:49:18 +0000 Subject: [PATCH] prototype redirect code which might be used to redirect in the future --- .../challenge/gui/ChallengerWebGUI.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/challenger/src/main/java/uk/co/compendiumdev/challenge/gui/ChallengerWebGUI.java b/challenger/src/main/java/uk/co/compendiumdev/challenge/gui/ChallengerWebGUI.java index 05b969c3..47b2bed7 100644 --- a/challenger/src/main/java/uk/co/compendiumdev/challenge/gui/ChallengerWebGUI.java +++ b/challenger/src/main/java/uk/co/compendiumdev/challenge/gui/ChallengerWebGUI.java @@ -19,14 +19,15 @@ import java.io.*; import java.lang.reflect.Array; +import java.net.MalformedURLException; +import java.net.URL; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; -import static spark.Spark.after; -import static spark.Spark.get; +import static spark.Spark.*; public class ChallengerWebGUI { @@ -72,6 +73,25 @@ public void setup(final Challengers challengers, // return ""; // }); + // could redirect to eviltester.com if the canonical doesn't change the search indexing from heroku to eviltester +// before((request, response) -> { +// +// if (request.requestMethod().equals("GET")) { +// if (request.url().startsWith("http://apichallenges.herokuapp.com") || +// request.url().startsWith("https://apichallenges.herokuapp.com") +// ) { +// // and it is a browser request +// if (request.headers("accept").contains("text/html")) { +// // then redirect +// response.header("location", "https://apichallenges.eviltester.com" + request.uri()); +// halt(301); +// } +// } else { +// System.out.println("nothing to see here"); +// } +// } +// } +// ); // single user / default session get("/gui/challenges", (request, result) -> {