MCPcopy Index your code
hub / github.com/tailscale/tailscale / ServeHTTP

Method ServeHTTP

tsweb/debug.go:76–99  ·  view source on GitHub ↗

ServeHTTP implements http.Handler.

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

Source from the content-addressed store, hash-verified

74
75// ServeHTTP implements http.Handler.
76func (d *DebugHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
77 if !AllowDebugAccess(r) {
78 http.Error(w, "debug access denied", http.StatusForbidden)
79 return
80 }
81 if r.URL.Path != "/debug/" {
82 // Sub-handlers are handled by the parent mux directly.
83 http.NotFound(w, r)
84 return
85 }
86
87 AddBrowserHeaders(w)
88 f := func(format string, args ...any) { fmt.Fprintf(w, format, args...) }
89 f("<html><body><h1>%s</h1><ul>", html.EscapeString(d.title))
90 for _, kv := range d.kvs {
91 kv(w)
92 }
93 for _, url := range d.urls {
94 io.WriteString(w, url)
95 }
96 for _, section := range d.sections {
97 section(w, r)
98 }
99}
100
101func (d *DebugHandler) handle(slug string, handler http.Handler) string {
102 href := "/debug/" + slug

Callers 1

Calls 5

AllowDebugAccessFunction · 0.85
AddBrowserHeadersFunction · 0.85
WriteStringMethod · 0.80
ErrorMethod · 0.65
kvStruct · 0.50

Tested by

no test coverage detected