mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-05 22:53:41 +02:00
add router group for http server (#1208)
This commit is contained in:
parent
078ca6bc9b
commit
4e529d1e30
@ -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(
|
||||
|
@ -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...)
|
||||
|
Loading…
Reference in New Issue
Block a user