|
@@ -12,6 +12,7 @@ import (
|
|
|
"github.com/docker/docker/api/server/httputils"
|
|
|
"github.com/docker/docker/api/server/middleware"
|
|
|
"github.com/docker/docker/api/server/router"
|
|
|
+ "github.com/docker/docker/api/server/router/debug"
|
|
|
"github.com/docker/docker/dockerversion"
|
|
|
"github.com/gorilla/mux"
|
|
|
"golang.org/x/net/context"
|
|
@@ -148,13 +149,10 @@ func (s *Server) makeHTTPHandler(handler httputils.APIFunc) http.HandlerFunc {
|
|
|
|
|
|
// InitRouter initializes the list of routers for the server.
|
|
|
// This method also enables the Go profiler if enableProfiler is true.
|
|
|
-func (s *Server) InitRouter(enableProfiler bool, routers ...router.Router) {
|
|
|
+func (s *Server) InitRouter(routers ...router.Router) {
|
|
|
s.routers = append(s.routers, routers...)
|
|
|
|
|
|
m := s.createMux()
|
|
|
- if enableProfiler {
|
|
|
- profilerSetup(m)
|
|
|
- }
|
|
|
s.routerSwapper = &routerSwapper{
|
|
|
router: m,
|
|
|
}
|
|
@@ -175,6 +173,13 @@ func (s *Server) createMux() *mux.Router {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ debugRouter := debug.NewRouter()
|
|
|
+ s.routers = append(s.routers, debugRouter)
|
|
|
+ for _, r := range debugRouter.Routes() {
|
|
|
+ f := s.makeHTTPHandler(r.Handler())
|
|
|
+ m.Path("/debug" + r.Path()).Handler(f)
|
|
|
+ }
|
|
|
+
|
|
|
err := errors.NewRequestNotFoundError(fmt.Errorf("page not found"))
|
|
|
notFoundHandler := httputils.MakeErrorHandler(err)
|
|
|
m.HandleFunc(versionMatcher+"/{path:.*}", notFoundHandler)
|
|
@@ -194,15 +199,3 @@ func (s *Server) Wait(waitChan chan error) {
|
|
|
}
|
|
|
waitChan <- nil
|
|
|
}
|
|
|
-
|
|
|
-// DisableProfiler reloads the server mux without adding the profiler routes.
|
|
|
-func (s *Server) DisableProfiler() {
|
|
|
- s.routerSwapper.Swap(s.createMux())
|
|
|
-}
|
|
|
-
|
|
|
-// EnableProfiler reloads the server mux adding the profiler routes.
|
|
|
-func (s *Server) EnableProfiler() {
|
|
|
- m := s.createMux()
|
|
|
- profilerSetup(m)
|
|
|
- s.routerSwapper.Swap(m)
|
|
|
-}
|