From 179ba7dea9246d878cd0458dd3c1886da55def91 Mon Sep 17 00:00:00 2001 From: daz-3ux Date: Tue, 12 Sep 2023 22:11:39 +0800 Subject: [PATCH] feat: add tencent 404 project page Signed-off-by: daz-3ux --- configs/404.html | 18 ++++++++++++++++++ internal/dazBlog/dazBlog.go | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 configs/404.html diff --git a/configs/404.html b/configs/404.html new file mode 100644 index 0000000..c2c36eb --- /dev/null +++ b/configs/404.html @@ -0,0 +1,18 @@ + + + + + + + + Tencent 404 Project + + + + + \ No newline at end of file diff --git a/internal/dazBlog/dazBlog.go b/internal/dazBlog/dazBlog.go index 1e4c056..b443a2a 100644 --- a/internal/dazBlog/dazBlog.go +++ b/internal/dazBlog/dazBlog.go @@ -84,8 +84,10 @@ func run() error { g := gin.New() // register 404 handler + g.LoadHTMLGlob("configs/*.html") g.NoRoute(func(c *gin.Context) { - c.JSON(http.StatusOK, gin.H{"code": 10003, "message": "404 Not Found"}) + //c.JSON(http.StatusOK, gin.H{"code": 10003, "message": "404 Not Found"}) + c.HTML(http.StatusNotFound, "404.html", gin.H{}) }) // register /healthz handler