Browse code

api/server: set /debug prefix as part of debug-router routes

Update the debug-router to include the prefix, instead of adding it
when registering the routes.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2024/12/08 22:27:26
Showing 2 changed files
... ...
@@ -24,13 +24,13 @@ type debugRouter struct {
24 24
 
25 25
 func (r *debugRouter) initRoutes() {
26 26
 	r.routes = []router.Route{
27
-		router.NewGetRoute("/vars", frameworkAdaptHandler(expvar.Handler())),
28
-		router.NewGetRoute("/pprof/", frameworkAdaptHandlerFunc(pprof.Index)),
29
-		router.NewGetRoute("/pprof/cmdline", frameworkAdaptHandlerFunc(pprof.Cmdline)),
30
-		router.NewGetRoute("/pprof/profile", frameworkAdaptHandlerFunc(pprof.Profile)),
31
-		router.NewGetRoute("/pprof/symbol", frameworkAdaptHandlerFunc(pprof.Symbol)),
32
-		router.NewGetRoute("/pprof/trace", frameworkAdaptHandlerFunc(pprof.Trace)),
33
-		router.NewGetRoute("/pprof/{name}", handlePprof),
27
+		router.NewGetRoute("/debug/vars", frameworkAdaptHandler(expvar.Handler())),
28
+		router.NewGetRoute("/debug/pprof/", frameworkAdaptHandlerFunc(pprof.Index)),
29
+		router.NewGetRoute("/debug/pprof/cmdline", frameworkAdaptHandlerFunc(pprof.Cmdline)),
30
+		router.NewGetRoute("/debug/pprof/profile", frameworkAdaptHandlerFunc(pprof.Profile)),
31
+		router.NewGetRoute("/debug/pprof/symbol", frameworkAdaptHandlerFunc(pprof.Symbol)),
32
+		router.NewGetRoute("/debug/pprof/trace", frameworkAdaptHandlerFunc(pprof.Trace)),
33
+		router.NewGetRoute("/debug/pprof/{name}", handlePprof),
34 34
 	}
35 35
 }
36 36
 
... ...
@@ -83,7 +83,7 @@ func (s *Server) CreateMux(routers ...router.Router) *mux.Router {
83 83
 	debugRouter := debug.NewRouter()
84 84
 	for _, r := range debugRouter.Routes() {
85 85
 		f := s.makeHTTPHandler(r.Handler(), r.Method()+" "+r.Path())
86
-		m.Path("/debug" + r.Path()).Handler(f)
86
+		m.Path(r.Path()).Handler(f)
87 87
 	}
88 88
 
89 89
 	notFoundHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {