[server] Move 404 handler to inside catch-all middleware

This commit is contained in:
Abhishek Shroff
2025-05-25 14:36:33 +05:30
parent be8f0caa57
commit 3feb42c0d7
2 changed files with 6 additions and 7 deletions
+6
View File
@@ -86,6 +86,12 @@ func setupWebApp(r gin.IRoutes, webAppSrcDir string) {
} else {
http.ServeFile(c.Writer, c.Request, indexFilePath)
}
} else {
c.JSON(http.StatusNotFound, gin.H{
"status": 404,
"code": "route_not_found",
"msg": "Route Not Found",
})
}
}
r.Use(staticFileHandler)
-7
View File
@@ -21,13 +21,6 @@ func createEngine() *gin.Engine {
"msg": "Internal Server Error",
})
}))
engine.NoRoute(func(c *gin.Context) {
c.JSON(http.StatusNotFound, gin.H{
"status": 404,
"code": "route_not_found",
"msg": "Route Not Found",
})
})
if Cfg.LogBody {
engine.Use(logBodyMiddleware)
}