2023-01-27 21:37:20 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2021-09-23 17:20:14 +01:00
|
|
|
|
2022-06-06 21:52:52 +01:00
|
|
|
//go:build !ios && !android && !js
|
2021-09-23 17:20:14 +01:00
|
|
|
|
|
|
|
// We don't include it on mobile where we're more memory constrained and
|
|
|
|
// there's no CLI to get at the results anyway.
|
|
|
|
|
|
|
|
package localapi
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"net/http/pprof"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2022-11-10 19:41:04 +00:00
|
|
|
servePprofFunc = servePprof
|
2021-09-23 17:20:14 +01:00
|
|
|
}
|
|
|
|
|
2022-11-10 19:41:04 +00:00
|
|
|
func servePprof(w http.ResponseWriter, r *http.Request) {
|
2021-09-23 17:20:14 +01:00
|
|
|
name := r.FormValue("name")
|
|
|
|
switch name {
|
|
|
|
case "profile":
|
|
|
|
pprof.Profile(w, r)
|
|
|
|
default:
|
|
|
|
pprof.Handler(name).ServeHTTP(w, r)
|
|
|
|
}
|
|
|
|
}
|