From 4551106e89a875ae053625f482ef3ed0a37f18f8 Mon Sep 17 00:00:00 2001 From: Marwane Date: Sun, 25 Feb 2024 12:47:05 +0100 Subject: [PATCH] adding customized error pages with a specific api for error handling --- .../app/GeorchestraGatewayApplication.java | 6 +++ .../main/resources/templates/error/403.html | 39 ++++++++++++++++ .../main/resources/templates/error/404.html | 39 ++++++++++++++++ .../main/resources/templates/error/500.html | 46 +++++++++++++++++++ .../main/resources/templates/error/501.html | 46 +++++++++++++++++++ .../main/resources/templates/error/503.html | 46 +++++++++++++++++++ 6 files changed, 222 insertions(+) create mode 100644 gateway/src/main/resources/templates/error/403.html create mode 100644 gateway/src/main/resources/templates/error/404.html create mode 100644 gateway/src/main/resources/templates/error/500.html create mode 100644 gateway/src/main/resources/templates/error/501.html create mode 100644 gateway/src/main/resources/templates/error/503.html diff --git a/gateway/src/main/java/org/georchestra/gateway/app/GeorchestraGatewayApplication.java b/gateway/src/main/java/org/georchestra/gateway/app/GeorchestraGatewayApplication.java index 4253b7e7..7653e7e2 100644 --- a/gateway/src/main/java/org/georchestra/gateway/app/GeorchestraGatewayApplication.java +++ b/gateway/src/main/java/org/georchestra/gateway/app/GeorchestraGatewayApplication.java @@ -48,6 +48,7 @@ import org.springframework.ui.Model; import org.springframework.util.unit.DataSize; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.server.ServerWebExchange; @@ -126,6 +127,11 @@ public String loginPage(@RequestParam Map allRequestParams, Mode return "login"; } + @GetMapping(path = "/error/{code}") + public String handleError(@PathVariable String code) { + return "error/" + code; + } + @EventListener(ApplicationReadyEvent.class) public void onApplicationReady(ApplicationReadyEvent e) { Environment env = e.getApplicationContext().getEnvironment(); diff --git a/gateway/src/main/resources/templates/error/403.html b/gateway/src/main/resources/templates/error/403.html new file mode 100644 index 00000000..09a00b88 --- /dev/null +++ b/gateway/src/main/resources/templates/error/403.html @@ -0,0 +1,39 @@ + + + + + + + + Access forbidden + + + +
+ geOrchestra +

Sorry, access to this page is forbidden. Return to the homepage.

+
+ + \ No newline at end of file diff --git a/gateway/src/main/resources/templates/error/404.html b/gateway/src/main/resources/templates/error/404.html new file mode 100644 index 00000000..fbd76a6e --- /dev/null +++ b/gateway/src/main/resources/templates/error/404.html @@ -0,0 +1,39 @@ + + + + + + + + Page not found + + + +
+ geOrchestra +

Page not found. Return to the homepage.

+
+ + \ No newline at end of file diff --git a/gateway/src/main/resources/templates/error/500.html b/gateway/src/main/resources/templates/error/500.html new file mode 100644 index 00000000..26a5b641 --- /dev/null +++ b/gateway/src/main/resources/templates/error/500.html @@ -0,0 +1,46 @@ + + + + + + + + Site en maintenance + + + +
+ geOrchestra +

+ Due to maintenance, this service is temporarily unavailable. +

+

We're sorry for the inconvenience !

+

Hint: do not close the tab - the requested page will show up in a few seconds.

+
+ + + \ No newline at end of file diff --git a/gateway/src/main/resources/templates/error/501.html b/gateway/src/main/resources/templates/error/501.html new file mode 100644 index 00000000..26a5b641 --- /dev/null +++ b/gateway/src/main/resources/templates/error/501.html @@ -0,0 +1,46 @@ + + + + + + + + Site en maintenance + + + +
+ geOrchestra +

+ Due to maintenance, this service is temporarily unavailable. +

+

We're sorry for the inconvenience !

+

Hint: do not close the tab - the requested page will show up in a few seconds.

+
+ + + \ No newline at end of file diff --git a/gateway/src/main/resources/templates/error/503.html b/gateway/src/main/resources/templates/error/503.html new file mode 100644 index 00000000..26a5b641 --- /dev/null +++ b/gateway/src/main/resources/templates/error/503.html @@ -0,0 +1,46 @@ + + + + + + + + Site en maintenance + + + +
+ geOrchestra +

+ Due to maintenance, this service is temporarily unavailable. +

+

We're sorry for the inconvenience !

+

Hint: do not close the tab - the requested page will show up in a few seconds.

+
+ + + \ No newline at end of file