mirror of
https://github.com/golang/go
synced 2024-11-18 17:14:45 -07:00
internal/lsp: switching debug pages to not use the default mux
Change-Id: I270fd1d4d44986aed6655da93e7388628f7b8b9c Reviewed-on: https://go-review.googlesource.com/c/tools/+/182467 Run-TryBot: Ian Cottrell <iancottrell@google.com> Run-TryBot: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
fdf1049a94
commit
ab136c9d47
@ -12,6 +12,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/pprof"
|
||||||
_ "net/http/pprof" // pull in the standard pprof handlers
|
_ "net/http/pprof" // pull in the standard pprof handlers
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -57,17 +58,6 @@ var (
|
|||||||
}{}
|
}{}
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
http.HandleFunc("/", Render(mainTmpl, func(*http.Request) interface{} { return data }))
|
|
||||||
http.HandleFunc("/debug/", Render(debugTmpl, nil))
|
|
||||||
http.HandleFunc("/cache/", Render(cacheTmpl, getCache))
|
|
||||||
http.HandleFunc("/session/", Render(sessionTmpl, getSession))
|
|
||||||
http.HandleFunc("/view/", Render(viewTmpl, getView))
|
|
||||||
http.HandleFunc("/file/", Render(fileTmpl, getFile))
|
|
||||||
http.HandleFunc("/info", Render(infoTmpl, getInfo))
|
|
||||||
http.HandleFunc("/memory", Render(memoryTmpl, getMemory))
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddCache adds a cache to the set being served
|
// AddCache adds a cache to the set being served
|
||||||
func AddCache(cache Cache) {
|
func AddCache(cache Cache) {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
@ -223,7 +213,21 @@ func Serve(ctx context.Context, addr string) error {
|
|||||||
}
|
}
|
||||||
log.Printf("Debug serving on port: %d", listener.Addr().(*net.TCPAddr).Port)
|
log.Printf("Debug serving on port: %d", listener.Addr().(*net.TCPAddr).Port)
|
||||||
go func() {
|
go func() {
|
||||||
if err := http.Serve(listener, nil); err != nil {
|
mux := http.NewServeMux()
|
||||||
|
mux.HandleFunc("/", Render(mainTmpl, func(*http.Request) interface{} { return data }))
|
||||||
|
mux.HandleFunc("/debug/", Render(debugTmpl, nil))
|
||||||
|
mux.HandleFunc("/debug/pprof/", pprof.Index)
|
||||||
|
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
|
||||||
|
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
||||||
|
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
||||||
|
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
||||||
|
mux.HandleFunc("/cache/", Render(cacheTmpl, getCache))
|
||||||
|
mux.HandleFunc("/session/", Render(sessionTmpl, getSession))
|
||||||
|
mux.HandleFunc("/view/", Render(viewTmpl, getView))
|
||||||
|
mux.HandleFunc("/file/", Render(fileTmpl, getFile))
|
||||||
|
mux.HandleFunc("/info", Render(infoTmpl, getInfo))
|
||||||
|
mux.HandleFunc("/memory", Render(memoryTmpl, getMemory))
|
||||||
|
if err := http.Serve(listener, mux); err != nil {
|
||||||
log.Printf("Debug server failed with %v", err)
|
log.Printf("Debug server failed with %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user