mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-22 02:50:42 +00:00
tsweb: replace NewMux with a more flexible DebugHandler.
Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:

committed by
Dave Anderson

parent
b461ba9554
commit
0022c3d2e2
@@ -37,30 +37,6 @@ func init() {
|
||||
// DevMode controls whether extra output in shown, for when the binary is being run in dev mode.
|
||||
var DevMode bool
|
||||
|
||||
// NewMux returns a new ServeMux with debugHandler registered (and protected) at /debug/.
|
||||
func NewMux(debugHandler http.Handler) *http.ServeMux {
|
||||
mux := http.NewServeMux()
|
||||
registerCommonDebug(mux)
|
||||
mux.Handle("/debug/", Protected(debugHandler))
|
||||
return mux
|
||||
}
|
||||
|
||||
func registerCommonDebug(mux *http.ServeMux) {
|
||||
mux.Handle("/debug/pprof/", Protected(http.DefaultServeMux)) // to net/http/pprof
|
||||
mux.Handle("/debug/vars", Protected(http.DefaultServeMux)) // to expvar
|
||||
mux.Handle("/debug/varz", Protected(http.HandlerFunc(VarzHandler)))
|
||||
mux.Handle("/debug/gc", Protected(http.HandlerFunc(gcHandler)))
|
||||
}
|
||||
|
||||
func gcHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("running GC...\n"))
|
||||
if f, ok := w.(http.Flusher); ok {
|
||||
f.Flush()
|
||||
}
|
||||
runtime.GC()
|
||||
w.Write([]byte("Done.\n"))
|
||||
}
|
||||
|
||||
func DefaultCertDir(leafDir string) string {
|
||||
cacheDir, err := os.UserCacheDir()
|
||||
if err == nil {
|
||||
|
Reference in New Issue
Block a user