Skip to content

Commit

Permalink
adding customized error pages with a specific api for error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
marwanehcine committed Feb 25, 2024
1 parent 95c775c commit 4551106
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -126,6 +127,11 @@ public String loginPage(@RequestParam Map<String, String> 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();
Expand Down
39 changes: 39 additions & 0 deletions gateway/src/main/resources/templates/error/403.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="robots" content="none" />
<meta name="googlebot" content="noarchive" />
<title>Access forbidden</title>
<style type="text/css">
body {
background-color:#e6e6e6;
font-family:Calibri;
text-align:center;
}
#wrapper {
background:#fff;
width:492px;
position:relative;
margin-left:auto;
margin-right:auto;
text-align:left;
border:3px solid #999;
overflow:hidden;
padding: 30px;
border-bottom-right-radius: 16px;
border-bottom-left-radius: 16px;
}
#wrapper p {
padding:5px;
}
</style>
</head>
<body lang=EN>
<div id="wrapper">
<img src="https://www.georchestra.org/public/logos/georchestra_logo.png" alt="geOrchestra" />
<p>Sorry, access to this page is forbidden. Return to the <a href="/">homepage</a>.</p>
</div>
</body>
</html>
39 changes: 39 additions & 0 deletions gateway/src/main/resources/templates/error/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="robots" content="none" />
<meta name="googlebot" content="noarchive" />
<title>Page not found</title>
<style type="text/css">
body {
background-color:#e6e6e6;
font-family:Calibri;
text-align:center;
}
#wrapper {
background:#fff;
width:492px;
position:relative;
margin-left:auto;
margin-right:auto;
text-align:left;
border:3px solid #999;
overflow:hidden;
padding: 30px;
border-bottom-right-radius: 16px;
border-bottom-left-radius: 16px;
}
#wrapper p {
padding:5px;
}
</style>
</head>
<body lang=EN>
<div id="wrapper">
<img src="https://www.georchestra.org/public/logos/georchestra_logo.png" alt="geOrchestra" />
<p>Page not found. Return to the <a href="/">homepage</a>.</p>
</div>
</body>
</html>
46 changes: 46 additions & 0 deletions gateway/src/main/resources/templates/error/500.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="robots" content="none" />
<meta name="googlebot" content="noarchive" />
<title>Site en maintenance</title>
<style type="text/css">
body {
background-color:#e6e6e6;
font-family:Calibri;
text-align:center;
}
#wrapper {
background:#fff;
width:492px;
position:relative;
margin-left:auto;
margin-right:auto;
text-align:left;
border:3px solid #999;
overflow:hidden;
padding: 30px;
border-bottom-right-radius: 16px;
border-bottom-left-radius: 16px;
}
#wrapper p {
padding:5px;
}
</style>
</head>
<body lang=FR>
<div id="wrapper">
<img src="https://www.georchestra.org/public/logos/georchestra_logo.png" alt="geOrchestra" />
<p>
Due to maintenance, this service is temporarily unavailable.
</p>
<p>We're sorry for the inconvenience !</p>
<p>Hint: do not close the tab - the requested page will show up in a few seconds.</p>
</div>
</body>
<script>
window.setTimeout(function() {window.location.href = window.location.href}, 5000);
</script>
</html>
46 changes: 46 additions & 0 deletions gateway/src/main/resources/templates/error/501.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="robots" content="none" />
<meta name="googlebot" content="noarchive" />
<title>Site en maintenance</title>
<style type="text/css">
body {
background-color:#e6e6e6;
font-family:Calibri;
text-align:center;
}
#wrapper {
background:#fff;
width:492px;
position:relative;
margin-left:auto;
margin-right:auto;
text-align:left;
border:3px solid #999;
overflow:hidden;
padding: 30px;
border-bottom-right-radius: 16px;
border-bottom-left-radius: 16px;
}
#wrapper p {
padding:5px;
}
</style>
</head>
<body lang=FR>
<div id="wrapper">
<img src="https://www.georchestra.org/public/logos/georchestra_logo.png" alt="geOrchestra" />
<p>
Due to maintenance, this service is temporarily unavailable.
</p>
<p>We're sorry for the inconvenience !</p>
<p>Hint: do not close the tab - the requested page will show up in a few seconds.</p>
</div>
</body>
<script>
window.setTimeout(function() {window.location.href = window.location.href}, 5000);
</script>
</html>
46 changes: 46 additions & 0 deletions gateway/src/main/resources/templates/error/503.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="robots" content="none" />
<meta name="googlebot" content="noarchive" />
<title>Site en maintenance</title>
<style type="text/css">
body {
background-color:#e6e6e6;
font-family:Calibri;
text-align:center;
}
#wrapper {
background:#fff;
width:492px;
position:relative;
margin-left:auto;
margin-right:auto;
text-align:left;
border:3px solid #999;
overflow:hidden;
padding: 30px;
border-bottom-right-radius: 16px;
border-bottom-left-radius: 16px;
}
#wrapper p {
padding:5px;
}
</style>
</head>
<body lang=FR>
<div id="wrapper">
<img src="https://www.georchestra.org/public/logos/georchestra_logo.png" alt="geOrchestra" />
<p>
Due to maintenance, this service is temporarily unavailable.
</p>
<p>We're sorry for the inconvenience !</p>
<p>Hint: do not close the tab - the requested page will show up in a few seconds.</p>
</div>
</body>
<script>
window.setTimeout(function() {window.location.href = window.location.href}, 5000);
</script>
</html>

0 comments on commit 4551106

Please sign in to comment.