diff --git a/ginext/engine.go b/ginext/engine.go index 8f43ad3..f1fbf12 100644 --- a/ginext/engine.go +++ b/ginext/engine.go @@ -51,6 +51,20 @@ type Options struct { // NewEngine creates a new (wrapped) ginEngine func NewEngine(opt Options) *GinWrapper { + ginDebug := langext.Coalesce(opt.GinDebug, true) + if ginDebug { + gin.SetMode(gin.DebugMode) + + // do not debug-print routes + gin.DebugPrintRouteFunc = func(_, _, _ string, _ int) {} + + } else { + gin.SetMode(gin.ReleaseMode) + + // do not debug-print routes + gin.DebugPrintRouteFunc = func(_, _, _ string, _ int) {} + } + engine := gin.New() wrapper := &GinWrapper{ @@ -58,7 +72,7 @@ func NewEngine(opt Options) *GinWrapper { opt: opt, suppressGinLogs: langext.Coalesce(opt.SuppressGinLogs, false), allowCors: langext.Coalesce(opt.AllowCors, false), - ginDebug: langext.Coalesce(opt.GinDebug, true), + ginDebug: ginDebug, bufferBody: langext.Coalesce(opt.BufferBody, false), requestTimeout: langext.Coalesce(opt.Timeout, 24*time.Hour), listenerBeforeRequest: opt.ListenerBeforeRequest, @@ -72,24 +86,10 @@ func NewEngine(opt Options) *GinWrapper { engine.Use(CorsMiddleware()) } - if wrapper.ginDebug { - gin.SetMode(gin.DebugMode) - - // do not debug-print routes - gin.DebugPrintRouteFunc = func(_, _, _ string, _ int) {} - - if !wrapper.suppressGinLogs { - ginlogger := gin.Logger() - engine.Use(func(context *gin.Context) { ginlogger(context) }) - } - - } else { - gin.SetMode(gin.ReleaseMode) - - // do not debug-print routes - gin.DebugPrintRouteFunc = func(_, _, _ string, _ int) {} + if ginDebug && !wrapper.suppressGinLogs { + ginlogger := gin.Logger() + engine.Use(func(context *gin.Context) { ginlogger(context) }) } - return wrapper } diff --git a/go.mod b/go.mod index 2f7749a..b993292 100644 --- a/go.mod +++ b/go.mod @@ -32,12 +32,12 @@ require ( github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.21.0 // indirect + github.com/go-playground/validator/v10 v10.22.0 // indirect github.com/goccy/go-json v0.10.3 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/uuid v1.5.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.17.8 // indirect + github.com/klauspost/compress v1.17.9 // indirect github.com/klauspost/cpuid/v2 v2.2.8 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect diff --git a/go.sum b/go.sum index f8d4816..ca4ac9c 100644 --- a/go.sum +++ b/go.sum @@ -81,6 +81,8 @@ github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBEx github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-playground/validator/v10 v10.21.0 h1:4fZA11ovvtkdgaeev9RGWPgc1uj3H8W+rNYyH/ySBb0= github.com/go-playground/validator/v10 v10.21.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao= +github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= @@ -120,6 +122,8 @@ github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLA github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= diff --git a/goextVersion.go b/goextVersion.go index 656ab82..e2b928d 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.471" +const GoextVersion = "0.0.472" -const GoextVersionTimestamp = "2024-06-11T19:39:43+0200" +const GoextVersionTimestamp = "2024-06-14T14:56:41+0200"