v0.0.436
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m56s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m56s
This commit is contained in:
@@ -19,6 +19,7 @@ type GinWrapper struct {
|
||||
engine *gin.Engine
|
||||
suppressGinLogs bool
|
||||
|
||||
opt Options
|
||||
allowCors bool
|
||||
ginDebug bool
|
||||
bufferBody bool
|
||||
@@ -37,13 +38,15 @@ type ginRouteSpec struct {
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
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)
|
||||
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
|
||||
Timeout *time.Duration // The default handler timeout
|
||||
ListenerBeforeRequest []func(g *gin.Context) // Register listener that are called before the handler method
|
||||
ListenerAfterRequest []func(g *gin.Context, resp HTTPResponse) // Register listener that are called after the handler method
|
||||
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)
|
||||
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
|
||||
Timeout *time.Duration // The default handler timeout
|
||||
ListenerBeforeRequest []func(g *gin.Context) // Register listener that are called before the handler method
|
||||
ListenerAfterRequest []func(g *gin.Context, resp HTTPResponse) // Register listener that are called after the handler method
|
||||
DebugTrimHandlerPrefixes []string // Trim these prefixes from the handler names in the debug print
|
||||
DebugReplaceHandlerNames map[string]string // Replace handler names in debug output
|
||||
}
|
||||
|
||||
// NewEngine creates a new (wrapped) ginEngine
|
||||
@@ -52,6 +55,7 @@ func NewEngine(opt Options) *GinWrapper {
|
||||
|
||||
wrapper := &GinWrapper{
|
||||
engine: engine,
|
||||
opt: opt,
|
||||
suppressGinLogs: langext.Coalesce(opt.SuppressGinLogs, false),
|
||||
allowCors: langext.Coalesce(opt.AllowCors, false),
|
||||
ginDebug: langext.Coalesce(opt.GinDebug, true),
|
||||
@@ -185,6 +189,18 @@ func (w *GinWrapper) cleanMiddlewareName(fname string) string {
|
||||
}
|
||||
}
|
||||
|
||||
for _, pfx := range w.opt.DebugTrimHandlerPrefixes {
|
||||
if strings.HasPrefix(fname, pfx) {
|
||||
fname = fname[len(pfx):]
|
||||
}
|
||||
}
|
||||
|
||||
for k, v := range langext.ForceMap(w.opt.DebugReplaceHandlerNames) {
|
||||
if strings.EqualFold(fname, k) {
|
||||
fname = v
|
||||
}
|
||||
}
|
||||
|
||||
return fname
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user