This commit is contained in:
parent
be9e6aaa81
commit
c37350a81f
|
@ -9,11 +9,13 @@ const rootTemplate = `<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head><title>PProf Web Interface</title></head>
|
<head><title>PProf Web Interface</title></head>
|
||||||
<body>
|
<body>
|
||||||
<p>Upload a file to explore it using the <a href="https://github.com/google/pprof">Pprof</a> web interface.
|
<p>Upload a file to explore it using the <a href="https://github.com/google/pprof">Pprof</a> web interface.</p>
|
||||||
|
|
||||||
the source code <a href="https://github.com/evanj/pprofweb">over here </a>.
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
the source code <a href="https://git.tuxpa.in/a/pprofweb">over here </a>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
code is based off <a href="https://github.com/evanj/pprofweb">this project</a>.
|
code is based off <a href="https://github.com/evanj/pprofweb">this project</a>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
@ -42,6 +44,15 @@ works with whatever works in the command line (it just runs go tool pprof in the
|
||||||
<form method="post" action="/upload" enctype="multipart/form-data">
|
<form method="post" action="/upload" enctype="multipart/form-data">
|
||||||
<p>Upload file: <input type="file" name="file"> <input type="submit" value="Upload"></p>
|
<p>Upload file: <input type="file" name="file"> <input type="submit" value="Upload"></p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
|
||||||
|
u can also use curl! basically it checks if your Accept headers have "http", and if not, then it will not redirect, and will send the id instead
|
||||||
|
curl -F file=@<filename> https://pprof.aaaaa.news/upload
|
||||||
|
|
||||||
|
|
||||||
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`
|
`
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -168,7 +169,13 @@ func (s *Server) handleUpload(w http.ResponseWriter, r *http.Request) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
http.Redirect(w, r, instance.id.String()+"/", http.StatusSeeOther)
|
for _, h := range r.Header.Values("Accept") {
|
||||||
|
if strings.Contains(h, "text/html") {
|
||||||
|
http.Redirect(w, r, instance.id.String()+"/", http.StatusSeeOther)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
w.Write([]byte(instance.id.String()))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +183,6 @@ type Instance struct {
|
||||||
id xid.ID
|
id xid.ID
|
||||||
dat []byte
|
dat []byte
|
||||||
|
|
||||||
setup sync.Once
|
|
||||||
handler http.Handler
|
handler http.Handler
|
||||||
|
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
|
@ -204,7 +210,6 @@ func (i *Instance) startHTTP(args *driver.HTTPServerArgs) error {
|
||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
for pattern, handler := range args.Handlers {
|
for pattern, handler := range args.Handlers {
|
||||||
jpat := "/" + path.Join(i.id.String(), pattern)
|
jpat := "/" + path.Join(i.id.String(), pattern)
|
||||||
log.Println(jpat)
|
|
||||||
r.Handle(jpat, handler)
|
r.Handle(jpat, handler)
|
||||||
r.Handle(jpat+"/", handler)
|
r.Handle(jpat+"/", handler)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue