api: Error pages routes

pull/1/head
Lunix-420 2024-11-11 16:45:26 +01:00
parent b53855e346
commit 9f647f49cd
2 changed files with 88 additions and 1 deletions

View File

@ -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";
}
}

View File

@ -4,24 +4,53 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; 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 @Controller
public class Page { public class Page {
/**
* Returns the home page.
*
* @param model The model with the data to be displayed.
* @return The home page template.
*/
@GetMapping({ "/", "" }) @GetMapping({ "/", "" })
public String home(Model model) { public String home(Model model) {
return "pages/core/home"; return "pages/core/home";
} }
/**
* Returns the impressum page.
*
* @return The impressum page template.
*/
@GetMapping("/impressum") @GetMapping("/impressum")
public String impressum() { public String impressum() {
return "pages/core/impressum"; return "pages/core/impressum";
} }
/**
* Returns the datenschutz page.
*
* @return The datenschutz page template.
*/
@GetMapping("/datenschutz") @GetMapping("/datenschutz")
public String datenschutz() { public String datenschutz() {
return "pages/core/datenschutz"; return "pages/core/datenschutz";
} }
/**
* Returns the notes page.
*
* @return The notes page template.
*/
@GetMapping("/notes") @GetMapping("/notes")
public String notes() { public String notes() {
return "pages/core/notes"; return "pages/core/notes";