v0.0.339
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m5s
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m5s
This commit is contained in:
@@ -6,8 +6,10 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/mathext"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/rext"
|
||||
"net"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -126,7 +128,7 @@ func (w *GinWrapper) DebugPrintRoutes() {
|
||||
line := [4]string{
|
||||
spec.Method,
|
||||
spec.URL,
|
||||
strings.Join(spec.Middlewares, " -> "),
|
||||
strings.Join(langext.ArrMap(spec.Middlewares, w.cleanMiddlewareName), " -> "),
|
||||
spec.Handler,
|
||||
}
|
||||
|
||||
@@ -147,3 +149,28 @@ func (w *GinWrapper) DebugPrintRoutes() {
|
||||
langext.StrPadRight(line[3], " ", pad[3]))
|
||||
}
|
||||
}
|
||||
|
||||
func (w *GinWrapper) cleanMiddlewareName(fname string) string {
|
||||
|
||||
funcSuffix := rext.W(regexp.MustCompile(`\.func[0-9]+(?:\.[0-9]+)*$`))
|
||||
if match, ok := funcSuffix.MatchFirst(fname); ok {
|
||||
fname = fname[:len(fname)-match.FullMatch().Length()]
|
||||
}
|
||||
|
||||
if strings.HasSuffix(fname, ".(*GinRoutesWrapper).WithJSONFilter") {
|
||||
fname = "[JSONFilter]"
|
||||
}
|
||||
|
||||
if fname == "ginext.BodyBuffer" {
|
||||
fname = "[BodyBuffer]"
|
||||
}
|
||||
|
||||
skipPrefixes := []string{"api.(*Handler).", "api."}
|
||||
for _, pfx := range skipPrefixes {
|
||||
if strings.HasPrefix(fname, pfx) {
|
||||
fname = fname[len(pfx):]
|
||||
}
|
||||
}
|
||||
|
||||
return fname
|
||||
}
|
||||
|
Reference in New Issue
Block a user