diff --git a/src/main/java/com/faforever/api/error/ErrorController.java b/src/main/java/com/faforever/api/error/ErrorController.java new file mode 100644 index 000000000..568e6c25d --- /dev/null +++ b/src/main/java/com/faforever/api/error/ErrorController.java @@ -0,0 +1,30 @@ +package com.faforever.api.error; + +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import javax.servlet.RequestDispatcher; +import javax.servlet.http.HttpServletRequest; + +@Controller +public class ErrorController implements org.springframework.boot.web.servlet.error.ErrorController { + @RequestMapping("/error") + public String handleError(HttpServletRequest request) { + Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); + + if (status != null) { + Integer statusCode = Integer.valueOf(status.toString()); + + if (statusCode == HttpStatus.NOT_FOUND.value()) { + return "404"; + } + } + return "error"; + } + + @Override + public String getErrorPath() { + return "/error"; + } +} diff --git a/src/main/resources/templates/404.html b/src/main/resources/templates/404.html new file mode 100644 index 000000000..3d913ed08 --- /dev/null +++ b/src/main/resources/templates/404.html @@ -0,0 +1,16 @@ + +
+ +