Skip to content

Commit cff745c

Browse files
authored
Implement 404 page not found (#77)
1 parent 9f8d162 commit cff745c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/webserver.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ func runWebServer() {
5858
// gin middleware to enable GZIP support
5959
router.Use(gzip.Gzip(gzip.DefaultCompression))
6060

61+
// set 404 not found page
62+
router.NoRoute(func(c *gin.Context) {
63+
c.JSON(404, gin.H{"code": "PAGE_NOT_FOUND", "message": "Page not found"})
64+
})
65+
6166
// disable proxy feature of gin
6267
_ = router.SetTrustedProxies(nil)
6368

0 commit comments

Comments
 (0)