From 9f647f49cd231128292ef97374b814dbc14bff58 Mon Sep 17 00:00:00 2001 From: Lunix-420 Date: Mon, 11 Nov 2024 16:45:26 +0100 Subject: [PATCH] api: Error pages routes --- .../backend/controllers/page/ErrorPage.java | 58 +++++++++++++++++++ .../backend/controllers/page/Page.java | 31 +++++++++- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/maradona/backend/controllers/page/ErrorPage.java diff --git a/src/main/java/com/maradona/backend/controllers/page/ErrorPage.java b/src/main/java/com/maradona/backend/controllers/page/ErrorPage.java new file mode 100644 index 0000000..b43024d --- /dev/null +++ b/src/main/java/com/maradona/backend/controllers/page/ErrorPage.java @@ -0,0 +1,58 @@ +package com.maradona.backend.controllers.page; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * Controller for routing to the error pages. + * + * List of endpoints: + * - GET /error/400 + * - GET /error/404 + * - GET /error/500 + */ +@Controller +@RequestMapping("/error") +public class ErrorPage { + /** + * Error page for 400 Bad Request. + * + * This page is displayed when the request is malformed and the server cannot + * process it. + * + * @return The 400 error page template. + */ + @GetMapping("/400") + public String error400() { + return "pages/error/400"; + } + + /** + * Error page for 404 Not Found. + * + * This page is displayed when the requested resource could not be found on the + * server. This can be due to a wrong URL or a deleted resource. The user should + * be informed that the resource is not available. + * + * @return The 404 error page template. + */ + @GetMapping("/404") + public String error404() { + return "pages/error/404"; + } + + /** + * Error page for 500 Internal Server Error. + * + * This page is displayed when the server encountered an unexpected condition + * that prevented it from fulfilling the request. The user should be informed + * that the server is experiencing problems and the request cannot be processed. + * + * @return The 500 error page template. + */ + @GetMapping("/500") + public String error500() { + return "pages/error/500"; + } +} diff --git a/src/main/java/com/maradona/backend/controllers/page/Page.java b/src/main/java/com/maradona/backend/controllers/page/Page.java index d252e55..18a74ac 100644 --- a/src/main/java/com/maradona/backend/controllers/page/Page.java +++ b/src/main/java/com/maradona/backend/controllers/page/Page.java @@ -4,24 +4,53 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +/** + * Controller for routing to the core pages. + * + * List of endpoints: + * - GET / + * - GET /impressum + * - GET /datenschutz + * - GET /notes + */ @Controller public class Page { - + /** + * Returns the home page. + * + * @param model The model with the data to be displayed. + * @return The home page template. + */ @GetMapping({ "/", "" }) public String home(Model model) { return "pages/core/home"; } + /** + * Returns the impressum page. + * + * @return The impressum page template. + */ @GetMapping("/impressum") public String impressum() { return "pages/core/impressum"; } + /** + * Returns the datenschutz page. + * + * @return The datenschutz page template. + */ @GetMapping("/datenschutz") public String datenschutz() { return "pages/core/datenschutz"; } + /** + * Returns the notes page. + * + * @return The notes page template. + */ @GetMapping("/notes") public String notes() { return "pages/core/notes";