From e8c34ab38e00bc3db1b1a59ae4cfaaf6602c43c2 Mon Sep 17 00:00:00 2001 From: vvbbnn00 Date: Sun, 10 Mar 2024 16:56:57 +0800 Subject: [PATCH] fix: Prevent printing sensitive logs in non-debug mode --- route/route.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/route/route.go b/route/route.go index 02a3f57..65f287f 100644 --- a/route/route.go +++ b/route/route.go @@ -17,8 +17,6 @@ import ( // RegisterRoutes load all the enabled routes for the application func RegisterRoutes() *gin.Engine { - router := gin.Default() - if config.GofletCfg.Debug { gin.SetMode(gin.DebugMode) gin.DefaultWriter = os.Stdout @@ -28,6 +26,9 @@ func RegisterRoutes() *gin.Engine { gin.DefaultWriter = io.Discard } + // Router should be created after setting the mode + router := gin.Default() + // Log the requests router.Use(middleware.SafeLogger())