MCPcopy
hub / github.com/netbirdio/netbird / ServeHTTP

Method ServeHTTP

proxy/internal/debug/handler.go:159–181  ·  view source on GitHub ↗

ServeHTTP handles debug requests.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

157
158// ServeHTTP handles debug requests.
159func (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
183func (h *Handler) handleClientRoutes(w http.ResponseWriter, r *http.Request, path string, wantJSON bool) bool {
184 if !strings.HasPrefix(path, "/debug/clients/") {

Calls 7

handleIndexMethod · 0.95
handleListClientsMethod · 0.95
handleHealthMethod · 0.95
handlePerfMethod · 0.95
handleRuntimeMethod · 0.95
handleClientRoutesMethod · 0.95
GetMethod · 0.65