From b4f6f06ab547b6ca52938180225f5f7bcddb17bb Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 22 Jan 2024 21:05:40 +0800 Subject: [PATCH] no printing internal middleware for `ghttp.Server` (#3271) --- net/ghttp/ghttp.go | 1 + net/ghttp/ghttp_server.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/net/ghttp/ghttp.go b/net/ghttp/ghttp.go index 6d53f66d6..ddee035da 100644 --- a/net/ghttp/ghttp.go +++ b/net/ghttp/ghttp.go @@ -161,6 +161,7 @@ const ( specialMethodNameShut = "Shut" specialMethodNameIndex = "Index" defaultEndpointPort = 80 + noPrintInternalRoute = "internalMiddlewareServerTracing" ) const ( diff --git a/net/ghttp/ghttp_server.go b/net/ghttp/ghttp_server.go index 96059856c..1da5ce4a3 100644 --- a/net/ghttp/ghttp_server.go +++ b/net/ghttp/ghttp_server.go @@ -301,6 +301,11 @@ func (s *Server) doRouterMapDump() { handlerName = gstr.TrimRightStr(item.Handler.Name, "-fm") middlewares = gstr.SplitAndTrim(item.Middleware, ",") ) + + // No printing special internal middleware that may lead confused. + if gstr.SubStrFromREx(handlerName, ".") == noPrintInternalRoute { + continue + } for k, v := range middlewares { middlewares[k] = gstr.TrimRightStr(v, "-fm") }