From 51902830ce43f4fa1584b83d7c7fe0886bd82e52 Mon Sep 17 00:00:00 2001 From: Suhaibinator <42899065+Suhaibinator@users.noreply.github.com> Date: Wed, 4 Feb 2026 17:22:27 -0800 Subject: [PATCH] Improve sanitizer warning details --- pkg/router/route.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/router/route.go b/pkg/router/route.go index e9b4891..833b75a 100644 --- a/pkg/router/route.go +++ b/pkg/router/route.go @@ -2,7 +2,9 @@ package router import ( "errors" + "fmt" "net/http" + "strings" "time" "github.com/Suhaibinator/SRouter/pkg/codec" @@ -71,15 +73,15 @@ func RegisterGenericRoute[Req any, Resp any, UserID comparable, User any]( ) { // Warn if no sanitizer function is provided (only at registration time) if route.Sanitizer == nil { - r.logger.Warn("Route registered without sanitizer function", + methods := make([]string, len(route.Methods)) + for i, method := range route.Methods { + methods[i] = string(method) + } + + r.logger.Warn( + fmt.Sprintf("Route registered without sanitizer function: %s %s", strings.Join(methods, ","), route.Path), zap.String("path", route.Path), - zap.Strings("methods", func() []string { - methods := make([]string, len(route.Methods)) - for i, method := range route.Methods { - methods[i] = string(method) - } - return methods - }()), + zap.Strings("methods", methods), ) }