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

Method ServeHTTP

tsweb/tsweb.go:196–213  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

194}
195
196func (h Port80Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
197 path := r.RequestURI
198 if path == "/debug" || strings.HasPrefix(path, "/debug") {
199 h.Main.ServeHTTP(w, r)
200 return
201 }
202 if r.Method != "GET" && r.Method != "HEAD" {
203 http.Error(w, "Use HTTPS", http.StatusBadRequest)
204 return
205 }
206 if path == "/" && AllowDebugAccess(r) {
207 // Redirect authorized user to the debug handler.
208 path = "/debug/"
209 }
210 host := cmp.Or(h.FQDN, r.Host)
211 target := "https://" + host + path
212 http.Redirect(w, r, target, http.StatusFound)
213}
214
215// ReturnHandler is like net/http.Handler, but the handler can return an
216// error instead of writing to its ResponseWriter.

Callers

nothing calls this directly

Calls 4

AllowDebugAccessFunction · 0.85
RedirectMethod · 0.80
ErrorMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected