package main func main() { r := mux.NewRouter() mount(r, "/api/v1", handler.Router(), auth) ... } // mount will take routers from a handler and add it with a pathprefix // mount will take routers from a handler and add it with a pathprefix func mount(r *mux.Router, path string, handler http.Handler, middleware mux.MiddlewareFunc) { r.PathPrefix(path).Handler( http.StripPrefix( strings.TrimSuffix(path, "/"), middleware(handler), ), ) }