@@ -86,6 +86,12 @@ import (
86
86
// FOR DEBUGGING ONLY. This will slow down the program.
87
87
var DebugUseAfterFinish = false
88
88
89
+ // HTTP ServeMux paths.
90
+ const (
91
+ debugRequestsPath = "/debug/requests"
92
+ debugEventsPath = "/debug/events"
93
+ )
94
+
89
95
// AuthRequest determines whether a specific request is permitted to load the
90
96
// /debug/requests or /debug/events pages.
91
97
//
@@ -112,17 +118,17 @@ var AuthRequest = func(req *http.Request) (any, sensitive bool) {
112
118
}
113
119
114
120
func init () {
115
- _ , pat := http .DefaultServeMux .Handler (& http.Request {URL : & url.URL {Path : "/debug/requests" }})
116
- if pat != "" {
121
+ _ , pat := http .DefaultServeMux .Handler (& http.Request {URL : & url.URL {Path : debugRequestsPath }})
122
+ if pat == debugRequestsPath {
117
123
panic ("/debug/requests is already registered. You may have two independent copies of " +
118
124
"golang.org/x/net/trace in your binary, trying to maintain separate state. This may " +
119
125
"involve a vendored copy of golang.org/x/net/trace." )
120
126
}
121
127
122
128
// TODO(jbd): Serve Traces from /debug/traces in the future?
123
129
// There is no requirement for a request to be present to have traces.
124
- http .HandleFunc ("/debug/requests" , Traces )
125
- http .HandleFunc ("/debug/events" , Events )
130
+ http .HandleFunc (debugRequestsPath , Traces )
131
+ http .HandleFunc (debugEventsPath , Events )
126
132
}
127
133
128
134
// NewContext returns a copy of the parent context
0 commit comments