diff --git a/examples/http/middlewares/main.go b/examples/http/middlewares/main.go index 4d63b00d7..940001010 100644 --- a/examples/http/middlewares/main.go +++ b/examples/http/middlewares/main.go @@ -30,8 +30,8 @@ func main() { // add path filter to custom route r.GET("/hello/{name}", sayHelloHandler, pathFilter, pathFilter2) - // add path filter to sub router - r2 := r.NewSubRouter("/v2", pathFilter, pathFilter2) + // add path filter to router group + r2 := r.Group("/v2", pathFilter, pathFilter2) r2.GET("/say/{name}", sayHelloHandler) app := kratos.New( diff --git a/transport/http/router.go b/transport/http/router.go index b0e36f85e..d8d5c08e8 100644 --- a/transport/http/router.go +++ b/transport/http/router.go @@ -29,8 +29,8 @@ func newRouter(prefix string, srv *Server, filters ...FilterFunc) *Router { return r } -// NewSubRouter returns a new sub router -func (r *Router) NewSubRouter(prefix string, filters ...FilterFunc) *Router { +// Group returns a new router group. +func (r *Router) Group(prefix string, filters ...FilterFunc) *Router { var newFilters []FilterFunc newFilters = append(newFilters, r.filters...) newFilters = append(newFilters, filters...)