diff options
author | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-08-31 02:05:36 +0300 |
---|---|---|
committer | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-08-31 02:05:36 +0300 |
commit | 5094ebf213243023c6325310b3f710a0974025dd (patch) | |
tree | 98b501b07271645f924b70af00bf8792d6062d65 /group.go | |
parent | 376839b264c7f77b2540ad9f83bd8baf44063f17 (diff) |
Обновление muxv0.0.1
Diffstat (limited to 'group.go')
-rw-r--r-- | group.go | 20 |
1 files changed, 5 insertions, 15 deletions
@@ -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 } |