From cfdc7a764405f48f0dba2684f1fbacf1d6c0a57c Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Sat, 12 Nov 2022 20:12:25 -0600 Subject: [PATCH] Custom 404 page --- src/main/java/tk/SinTan1729/url/Routes.java | 2 +- src/main/resources/public/404.html | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/public/404.html diff --git a/src/main/java/tk/SinTan1729/url/Routes.java b/src/main/java/tk/SinTan1729/url/Routes.java index 5cd2b6a..42c6037 100644 --- a/src/main/java/tk/SinTan1729/url/Routes.java +++ b/src/main/java/tk/SinTan1729/url/Routes.java @@ -58,7 +58,7 @@ public class Routes { .findForShortUrl(shortUrl); if (longUrlOpt.isEmpty()) { - res.status(404); + res.redirect("404.html"); return ""; } urlRepository.addHit(shortUrl); diff --git a/src/main/resources/public/404.html b/src/main/resources/public/404.html new file mode 100644 index 0000000..f3e56f2 --- /dev/null +++ b/src/main/resources/public/404.html @@ -0,0 +1,14 @@ + + + + + Error 404 + + + + +

Error 404!

+ It's okay, we all make mistakes. + + + \ No newline at end of file