From 5094ebf213243023c6325310b3f710a0974025dd Mon Sep 17 00:00:00 2001 From: Alexander Neonxp Kiryukhin Date: Sat, 31 Aug 2024 02:05:36 +0300 Subject: Обновление mux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'group.go') diff --git a/group.go b/group.go index ad8f82a..319b152 100644 --- a/group.go +++ b/group.go @@ -1,18 +1,8 @@ package mux -import ( - "net/http" - "strings" -) - -func Group(mux *http.ServeMux, prefix string, group func(sm *http.ServeMux), middlewares ...Middleware) { - groupMux := http.NewServeMux() - group(groupMux) - if !strings.HasSuffix(prefix, "/") { - prefix += "/" - } - mux.Handle( - prefix, - http.StripPrefix(strings.TrimSuffix(prefix, "/"), Use(groupMux, middlewares...)), - ) +func (m *Mux) Group(prefix string, group func(sm *Mux), middlewares ...Middleware) { + child := New() + group(child) + child.Use(middlewares...) + m.groups[prefix] = child } -- cgit v1.2.3