|
|
@ -110,7 +110,7 @@ func NewServer(opts ...ServerOption) *Server { |
|
|
|
return srv |
|
|
|
return srv |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// RouteGroup .
|
|
|
|
// RouteGroup returns a new route group for the URL path prefix.
|
|
|
|
func (s *Server) RouteGroup(prefix string) *RouteGroup { |
|
|
|
func (s *Server) RouteGroup(prefix string) *RouteGroup { |
|
|
|
return &RouteGroup{prefix: prefix, router: s.router} |
|
|
|
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) |
|
|
|
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.
|
|
|
|
// ServeHTTP should write reply headers and data to the ResponseWriter and then return.
|
|
|
|
func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request) { |
|
|
|
func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request) { |
|
|
|
ctx, cancel := context.WithTimeout(req.Context(), s.timeout) |
|
|
|
ctx, cancel := context.WithTimeout(req.Context(), s.timeout) |
|
|
|