@@ -110,30 +110,46 @@ var AuthRequest = func(req *http.Request) (any, sensitive bool) {
110
110
}
111
111
112
112
func init () {
113
- http .HandleFunc ("/debug/requests" , func (w http.ResponseWriter , req * http.Request ) {
114
- any , sensitive := AuthRequest (req )
115
- if ! any {
116
- http .Error (w , "not allowed" , http .StatusUnauthorized )
117
- return
118
- }
119
- w .Header ().Set ("Content-Type" , "text/html; charset=utf-8" )
120
- Render (w , req , sensitive )
121
- })
122
- http .HandleFunc ("/debug/events" , func (w http.ResponseWriter , req * http.Request ) {
123
- any , sensitive := AuthRequest (req )
124
- if ! any {
125
- http .Error (w , "not allowed" , http .StatusUnauthorized )
126
- return
127
- }
128
- w .Header ().Set ("Content-Type" , "text/html; charset=utf-8" )
129
- RenderEvents (w , req , sensitive )
130
- })
113
+ // TODO(jbd): Serve Traces from /debug/traces in the future?
114
+ // There is no requirement for a request to be present to have traces.
115
+ http .HandleFunc ("/debug/requests" , Traces )
116
+ http .HandleFunc ("/debug/events" , Events )
117
+ }
118
+
119
+ // Traces responds with traces from the program.
120
+ // The package initialization registers it in http.DefaultServeMux
121
+ // at /debug/requests.
122
+ //
123
+ // It performs authorization by running AuthRequest.
124
+ func Traces (w http.ResponseWriter , req * http.Request ) {
125
+ any , sensitive := AuthRequest (req )
126
+ if ! any {
127
+ http .Error (w , "not allowed" , http .StatusUnauthorized )
128
+ return
129
+ }
130
+ w .Header ().Set ("Content-Type" , "text/html; charset=utf-8" )
131
+ Render (w , req , sensitive )
132
+ }
133
+
134
+ // Events responds with a page of events collected by EventLogs.
135
+ // The package initialization registers it in http.DefaultServeMux
136
+ // at /debug/events.
137
+ //
138
+ // It performs authorization by running AuthRequest.
139
+ func Events (w http.ResponseWriter , req * http.Request ) {
140
+ any , sensitive := AuthRequest (req )
141
+ if ! any {
142
+ http .Error (w , "not allowed" , http .StatusUnauthorized )
143
+ return
144
+ }
145
+ w .Header ().Set ("Content-Type" , "text/html; charset=utf-8" )
146
+ RenderEvents (w , req , sensitive )
131
147
}
132
148
133
149
// Render renders the HTML page typically served at /debug/requests.
134
- // It does not do any auth checking; see AuthRequest for the default auth check
135
- // used by the handler registered on http.DefaultServeMux.
136
- // req may be nil .
150
+ // It does not do any auth checking. The request may be nil.
151
+ //
152
+ // Most users will use the Traces handler .
137
153
func Render (w io.Writer , req * http.Request , sensitive bool ) {
138
154
data := & struct {
139
155
Families []string
0 commit comments