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

Method ServeRedirectHTTP

safeweb/http.go:391–402  ·  view source on GitHub ↗

ServeRedirectHTTP serves a single HTTP handler on the provided listener that redirects all incoming HTTP requests to the HTTPS address of the provided fully qualified domain name (FQDN). Callers are responsible for closing the listener.

(ln net.Listener, fqdn string)

Source from the content-addressed store, hash-verified

389// fully qualified domain name (FQDN). Callers are responsible for closing the
390// listener.
391func (s *Server) ServeRedirectHTTP(ln net.Listener, fqdn string) error {
392 return http.Serve(ln, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
393 new := url.URL{
394 Scheme: "https",
395 Host: fqdn,
396 Path: r.URL.Path,
397 RawQuery: r.URL.RawQuery,
398 }
399
400 http.Redirect(w, r, new.String(), http.StatusMovedPermanently)
401 }))
402}
403
404// Serve starts the server and listens on the provided listener. It will block
405// until the server is closed. The caller is responsible for closing the

Callers

nothing calls this directly

Calls 3

RedirectMethod · 0.80
StringMethod · 0.65
ServeMethod · 0.45

Tested by

no test coverage detected