From 4e529d1e30dc147e9f7907ab6fc90beada34f49e Mon Sep 17 00:00:00 2001 From: longxboy Date: Sun, 18 Jul 2021 20:12:20 +0800 Subject: [PATCH] add router group for http server (#1208) --- examples/http/middlewares/main.go | 4 ++-- transport/http/router.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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...)