diff --git a/transport/http/server.go b/transport/http/server.go index a4dd39ce7..4e42f9fb7 100644 --- a/transport/http/server.go +++ b/transport/http/server.go @@ -110,7 +110,7 @@ func NewServer(opts ...ServerOption) *Server { return srv } -// RouteGroup . +// RouteGroup returns a new route group for the URL path prefix. func (s *Server) RouteGroup(prefix string) *RouteGroup { return &RouteGroup{prefix: prefix, router: s.router} } @@ -125,6 +125,11 @@ func (s *Server) HandleFunc(path string, h http.HandlerFunc) { s.router.HandleFunc(path, h) } +// PrefixHanlde registers a new route with a matcher for the URL path prefix. +func (s *Server) PrefixHanlde(prefix string, h http.Handler) { + s.router.PathPrefix(prefix).Handler(h) +} + // ServeHTTP should write reply headers and data to the ResponseWriter and then return. func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request) { ctx, cancel := context.WithTimeout(req.Context(), s.timeout)