|
|
@@ -86,6 +86,12 @@ import (
|
|
|
// FOR DEBUGGING ONLY. This will slow down the program.
|
|
|
var DebugUseAfterFinish = false
|
|
|
|
|
|
+// HTTP ServeMux paths.
|
|
|
+const (
|
|
|
+ debugRequestsPath = "/debug/requests"
|
|
|
+ debugEventsPath = "/debug/events"
|
|
|
+)
|
|
|
+
|
|
|
// AuthRequest determines whether a specific request is permitted to load the
|
|
|
// /debug/requests or /debug/events pages.
|
|
|
//
|
|
|
@@ -112,8 +118,8 @@ var AuthRequest = func(req *http.Request) (any, sensitive bool) {
|
|
|
}
|
|
|
|
|
|
func init() {
|
|
|
- _, pat := http.DefaultServeMux.Handler(&http.Request{URL: &url.URL{Path: "/debug/requests"}})
|
|
|
- if pat != "" {
|
|
|
+ _, pat := http.DefaultServeMux.Handler(&http.Request{URL: &url.URL{Path: debugRequestsPath}})
|
|
|
+ if pat == debugRequestsPath {
|
|
|
panic("/debug/requests is already registered. You may have two independent copies of " +
|
|
|
"golang.org/x/net/trace in your binary, trying to maintain separate state. This may " +
|
|
|
"involve a vendored copy of golang.org/x/net/trace.")
|
|
|
@@ -121,8 +127,8 @@ func init() {
|
|
|
|
|
|
// TODO(jbd): Serve Traces from /debug/traces in the future?
|
|
|
// There is no requirement for a request to be present to have traces.
|
|
|
- http.HandleFunc("/debug/requests", Traces)
|
|
|
- http.HandleFunc("/debug/events", Events)
|
|
|
+ http.HandleFunc(debugRequestsPath, Traces)
|
|
|
+ http.HandleFunc(debugEventsPath, Events)
|
|
|
}
|
|
|
|
|
|
// NewContext returns a copy of the parent context
|