From b876c64ba2f9e51df679ade58f2cb9655060e254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Thu, 18 Apr 2024 14:09:26 +0200 Subject: [PATCH] v0.0.436 --- ginext/engine.go | 30 +++++++++++++++++++++++------- go.mod | 7 ++++--- go.sum | 9 +++++++++ goextVersion.go | 4 ++-- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/ginext/engine.go b/ginext/engine.go index 42a4aaf..268ead6 100644 --- a/ginext/engine.go +++ b/ginext/engine.go @@ -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 } diff --git a/go.mod b/go.mod index 2064407..0d26bf5 100644 --- a/go.mod +++ b/go.mod @@ -15,11 +15,12 @@ require ( ) require ( - github.com/bytedance/sonic v1.11.4 // indirect + github.com/bytedance/sonic v1.11.5 // indirect + github.com/bytedance/sonic/loader v0.1.1 // indirect github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect github.com/chenzhuoyu/iasm v0.9.1 // indirect - github.com/cloudwego/base64x v0.1.0 // indirect - github.com/cloudwego/iasm v0.1.0 // indirect + github.com/cloudwego/base64x v0.1.3 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gin-contrib/sse v0.1.0 // indirect diff --git a/go.sum b/go.sum index 51e74e5..df5f272 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,11 @@ github.com/bytedance/sonic v1.11.3 h1:jRN+yEjakWh8aK5FzrciUHG8OFXK+4/KrAX/ysEtHA github.com/bytedance/sonic v1.11.3/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4= github.com/bytedance/sonic v1.11.4 h1:8+OMLSSDDm2/qJc6ld5K5Sm62NK9VHcUKk0NzBoMAM4= github.com/bytedance/sonic v1.11.4/go.mod h1:YrWEqYtlBPS6LUA0vpuG79a1trsh4Ae41uWUWUreHhE= +github.com/bytedance/sonic v1.11.5 h1:G00FYjjqll5iQ1PYXynbg/hyzqBqavH8Mo9/oTopd9k= +github.com/bytedance/sonic v1.11.5/go.mod h1:X2PC2giUdj/Cv2lliWFLk6c/DUQok5rViJSemeB0wDw= +github.com/bytedance/sonic/loader v0.1.0/go.mod h1:UmRT+IRTGKz/DAkzcEGzyVqQFJ7H9BqwBO3pm9H/+HY= +github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0= @@ -21,9 +26,13 @@ github.com/chenzhuoyu/iasm v0.9.1 h1:tUHQJXo3NhBqw6s33wkGn9SP3bvrWLdlVIJ3hQBL7P0 github.com/chenzhuoyu/iasm v0.9.1/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog= github.com/cloudwego/base64x v0.1.0 h1:Tg5q9tq1khq9Y9UwfoC6zkHK0FypN2GLDvhqFceOL8U= github.com/cloudwego/base64x v0.1.0/go.mod h1:lM8nFiNbg74QgesNo6EAtv8N9tlRjBWExmHoNDa3PkU= +github.com/cloudwego/base64x v0.1.3 h1:b5J/l8xolB7dyDTTmhJP2oTs5LdrjyrUFuNxdfq5hAg= +github.com/cloudwego/base64x v0.1.3/go.mod h1:1+1K5BUHIQzyapgpF7LwvOGAEDicKtt1umPV+aN8pi8= github.com/cloudwego/iasm v0.0.9/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cloudwego/iasm v0.1.0 h1:q0OuhwWDMyi3nlrQ6kIr0Yx0c3FI6cq/OZWKodIDdz8= github.com/cloudwego/iasm v0.1.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= +github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/goextVersion.go b/goextVersion.go index f956f6f..3328286 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.435" +const GoextVersion = "0.0.436" -const GoextVersionTimestamp = "2024-04-15T12:55:44+0200" +const GoextVersionTimestamp = "2024-04-18T14:09:26+0200"