summaryrefslogtreecommitdiff
path: root/group.go
diff options
context:
space:
mode:
Diffstat (limited to 'group.go')
-rw-r--r--group.go20
1 files changed, 5 insertions, 15 deletions
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
}