blob: ad8f82a366ac70d085deb75dc405c872a444f5c0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
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...)),
)
}
|