v0.0.472 changed gin engine initialization
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m34s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m34s
This commit is contained in:
parent
f6121a6961
commit
94a7bf250d
@ -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 {
|
||||
if ginDebug && !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) {}
|
||||
}
|
||||
|
||||
return wrapper
|
||||
}
|
||||
|
||||
|
4
go.mod
4
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
|
||||
|
4
go.sum
4
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=
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user