diff --git a/server/src/main/java/xyz/e3ndr/athena/webui/AthenaUIServer.java b/server/src/main/java/xyz/e3ndr/athena/webui/AthenaUIServer.java index d63b0bd..6e78df9 100644 --- a/server/src/main/java/xyz/e3ndr/athena/webui/AthenaUIServer.java +++ b/server/src/main/java/xyz/e3ndr/athena/webui/AthenaUIServer.java @@ -46,6 +46,7 @@ public static class AthenaSoraAdapter extends SoraPlugin { @Override public void onInit(Sora sora) { + sora.addProvider(this, new UIRoutes()); } @Override diff --git a/server/src/main/java/xyz/e3ndr/athena/webui/UIRoutes.java b/server/src/main/java/xyz/e3ndr/athena/webui/UIRoutes.java new file mode 100644 index 0000000..a05df03 --- /dev/null +++ b/server/src/main/java/xyz/e3ndr/athena/webui/UIRoutes.java @@ -0,0 +1,49 @@ +package xyz.e3ndr.athena.webui; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +import co.casterlabs.rakurai.io.http.StandardHttpStatus; +import co.casterlabs.rakurai.io.http.server.HttpResponse; +import co.casterlabs.sora.api.http.HttpProvider; +import co.casterlabs.sora.api.http.SoraHttpSession; +import co.casterlabs.sora.api.http.annotations.HttpEndpoint; + +class UIRoutes implements HttpProvider { + + @HttpEndpoint(uri = "/*") + public HttpResponse redirectToUI(SoraHttpSession session) { + return html( + "

Welcome to Athena!

", + ); + } + + private static HttpResponse html(String... body) { + List lines = new LinkedList<>(); + lines.addAll( + Arrays.asList( + "", + "", + " ", + " ", + " ", + " ", + " Athena", + " ", + " " + ) + ); + lines.addAll(Arrays.asList(body)); + lines.addAll( + Arrays.asList( + " ", + "" + ) + ); + return HttpResponse + .newFixedLengthResponse(StandardHttpStatus.OK, String.join("\r\n", lines)) + .setMimeType("text/html"); + } + +}