MCPcopy
hub / github.com/tailscale/golink / serveHandler

Function serveHandler

golink.go:412–432  ·  view source on GitHub ↗

serverHandler returns the main http.Handler for serving all requests.

()

Source from the content-addressed store, hash-verified

410
411// serverHandler returns the main http.Handler for serving all requests.
412func serveHandler() http.Handler {
413 mux := http.NewServeMux()
414 mux.HandleFunc("/.detail/", serveDetail)
415 mux.HandleFunc("/.export", serveExport)
416 mux.HandleFunc("/.help", serveHelp)
417 mux.HandleFunc("/.opensearch", serveOpenSearch)
418 mux.HandleFunc("/.all", serveAll)
419 mux.HandleFunc("/.delete/", serveDelete)
420 mux.Handle("/.static/", http.StripPrefix("/.", http.FileServer(http.FS(embeddedFS))))
421
422 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
423 // all internal URLs begin with a leading "."; any other URL is treated as a go link.
424 // Serve go links directly without passing through the ServeMux,
425 // which sometimes modifies the request URL path, which we don't want.
426 if !strings.HasPrefix(r.URL.Path, "/.") {
427 serveGo(w, r)
428 return
429 }
430 mux.ServeHTTP(w, r)
431 })
432}
433
434func serveHome(w http.ResponseWriter, r *http.Request, short string) {
435 var clicks []visitData

Callers 3

RunFunction · 0.85
TestServeGoFunction · 0.85
TestNoHSTSShortDomainFunction · 0.85

Calls 1

serveGoFunction · 0.85

Tested by 2

TestServeGoFunction · 0.68
TestNoHSTSShortDomainFunction · 0.68