This commit is contained in:
parent
be9e6aaa81
commit
c37350a81f
|
@ -9,11 +9,13 @@ const rootTemplate = `<!doctype html>
|
|||
<html>
|
||||
<head><title>PProf Web Interface</title></head>
|
||||
<body>
|
||||
<p>Upload a file to explore it using the <a href="https://github.com/google/pprof">Pprof</a> web interface.
|
||||
|
||||
the source code <a href="https://github.com/evanj/pprofweb">over here </a>.
|
||||
<p>Upload a file to explore it using the <a href="https://github.com/google/pprof">Pprof</a> web interface.</p>
|
||||
|
||||
<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>.
|
||||
</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">
|
||||
<p>Upload file: <input type="file" name="file"> <input type="submit" value="Upload"></p>
|
||||
</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>
|
||||
</html>
|
||||
`
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -168,7 +169,13 @@ func (s *Server) handleUpload(w http.ResponseWriter, r *http.Request) error {
|
|||
if err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -176,7 +183,6 @@ type Instance struct {
|
|||
id xid.ID
|
||||
dat []byte
|
||||
|
||||
setup sync.Once
|
||||
handler http.Handler
|
||||
|
||||
mu sync.RWMutex
|
||||
|
@ -204,7 +210,6 @@ func (i *Instance) startHTTP(args *driver.HTTPServerArgs) error {
|
|||
r := chi.NewRouter()
|
||||
for pattern, handler := range args.Handlers {
|
||||
jpat := "/" + path.Join(i.id.String(), pattern)
|
||||
log.Println(jpat)
|
||||
r.Handle(jpat, handler)
|
||||
r.Handle(jpat+"/", handler)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue