|
|
@@ -39,6 +39,7 @@ type ginRouteSpec struct {
|
|
|
|
type Options struct {
|
|
|
|
type Options struct {
|
|
|
|
AllowCors *bool // Add cors handler to allow all CORS requests on the default http methods
|
|
|
|
AllowCors *bool // Add cors handler to allow all CORS requests on the default http methods
|
|
|
|
GinDebug *bool // Set gin.debug to true (adds more logs)
|
|
|
|
GinDebug *bool // Set gin.debug to true (adds more logs)
|
|
|
|
|
|
|
|
SuppressGinLogs *bool // Suppress our custom gin logs (even if GinDebug == true)
|
|
|
|
BufferBody *bool // Buffers the input body stream, this way the ginext error handler can later include the whole request body
|
|
|
|
BufferBody *bool // Buffers the input body stream, this way the ginext error handler can later include the whole request body
|
|
|
|
Timeout *time.Duration // The default handler timeout
|
|
|
|
Timeout *time.Duration // The default handler timeout
|
|
|
|
ListenerBeforeRequest []func(g *gin.Context) // Register listener that are called before the handler method
|
|
|
|
ListenerBeforeRequest []func(g *gin.Context) // Register listener that are called before the handler method
|
|
|
@@ -51,7 +52,7 @@ func NewEngine(opt Options) *GinWrapper {
|
|
|
|
|
|
|
|
|
|
|
|
wrapper := &GinWrapper{
|
|
|
|
wrapper := &GinWrapper{
|
|
|
|
engine: engine,
|
|
|
|
engine: engine,
|
|
|
|
suppressGinLogs: false,
|
|
|
|
suppressGinLogs: langext.Coalesce(opt.SuppressGinLogs, false),
|
|
|
|
allowCors: langext.Coalesce(opt.AllowCors, false),
|
|
|
|
allowCors: langext.Coalesce(opt.AllowCors, false),
|
|
|
|
ginDebug: langext.Coalesce(opt.GinDebug, true),
|
|
|
|
ginDebug: langext.Coalesce(opt.GinDebug, true),
|
|
|
|
bufferBody: langext.Coalesce(opt.BufferBody, false),
|
|
|
|
bufferBody: langext.Coalesce(opt.BufferBody, false),
|
|
|
@@ -73,12 +74,12 @@ func NewEngine(opt Options) *GinWrapper {
|
|
|
|
if !wrapper.ginDebug {
|
|
|
|
if !wrapper.ginDebug {
|
|
|
|
gin.SetMode(gin.ReleaseMode)
|
|
|
|
gin.SetMode(gin.ReleaseMode)
|
|
|
|
|
|
|
|
|
|
|
|
ginlogger := gin.Logger()
|
|
|
|
if !wrapper.suppressGinLogs {
|
|
|
|
engine.Use(func(context *gin.Context) {
|
|
|
|
ginlogger := gin.Logger()
|
|
|
|
if !wrapper.suppressGinLogs {
|
|
|
|
engine.Use(func(context *gin.Context) {
|
|
|
|
ginlogger(context)
|
|
|
|
ginlogger(context)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
gin.SetMode(gin.DebugMode)
|
|
|
|
gin.SetMode(gin.DebugMode)
|
|
|
|
}
|
|
|
|
}
|
|
|
|