Skip to content

Commit

Permalink
feat(transport/http): add walk http handler (go-kratos#2943)
Browse files Browse the repository at this point in the history
* add walk http handler
  • Loading branch information
tonybase committed Aug 3, 2023
1 parent 072b2ee commit 3109546
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions transport/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ func (s *Server) WalkRoute(fn WalkRouteFunc) error {
})
}

// WalkHandle walks the router and all its sub-routers, calling walkFn for each route in the tree.
func (s *Server) WalkHandle(handle func(method, path string, handler http.HandlerFunc)) error {
return s.WalkRoute(func(r RouteInfo) error {
handle(r.Method, r.Path, s.ServeHTTP)
return nil
})
}

// Route registers an HTTP router.
func (s *Server) Route(prefix string, filters ...FilterFunc) *Router {
return newRouter(prefix, s, filters...)
Expand Down

0 comments on commit 3109546

Please sign in to comment.