Skip to content

Commit 707d1af

Browse files
committed
implement 404 page not found
1 parent 62f0a57 commit 707d1af

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
@@ -56,6 +56,11 @@ func runWebServer() {
5656
// gin middleware to enable GZIP support
5757
router.Use(gzip.Gzip(gzip.DefaultCompression))
5858

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

0 commit comments

Comments
 (0)