ServeHTTP handles debug requests.
(w http.ResponseWriter, r *http.Request)
| 157 | |
| 158 | // ServeHTTP handles debug requests. |
| 159 | func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| 160 | path := r.URL.Path |
| 161 | wantJSON := r.URL.Query().Get("format") == "json" || strings.HasSuffix(path, "/json") |
| 162 | path = strings.TrimSuffix(path, "/json") |
| 163 | |
| 164 | switch path { |
| 165 | case "/debug", "/debug/": |
| 166 | h.handleIndex(w, r, wantJSON) |
| 167 | case "/debug/clients": |
| 168 | h.handleListClients(w, r, wantJSON) |
| 169 | case "/debug/health": |
| 170 | h.handleHealth(w, r, wantJSON) |
| 171 | case "/debug/perf": |
| 172 | h.handlePerf(w, r) |
| 173 | case "/debug/runtime": |
| 174 | h.handleRuntime(w, r) |
| 175 | default: |
| 176 | if h.handleClientRoutes(w, r, path, wantJSON) { |
| 177 | return |
| 178 | } |
| 179 | http.NotFound(w, r) |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | func (h *Handler) handleClientRoutes(w http.ResponseWriter, r *http.Request, path string, wantJSON bool) bool { |
| 184 | if !strings.HasPrefix(path, "/debug/clients/") { |