Add profiling handlers

Amolith created

Change summary

main.go | 6 ++++++
1 file changed, 6 insertions(+)

Detailed changes

main.go 🔗

@@ -8,6 +8,7 @@ import (
 	"embed"
 	"log"
 	"net/http"
+	"net/http/pprof"
 
 	"github.com/dgraph-io/badger/v3"
 	flag "github.com/spf13/pflag"
@@ -63,6 +64,11 @@ func main() {
 	mux.HandleFunc("/read", m.readHandler)
 	mux.HandleFunc("/delete", m.deleteHandler)
 	mux.HandleFunc("/update", m.updateHandler)
+	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)
 
 	if err = httpServer.ListenAndServe(); err == http.ErrServerClosed {
 		log.Println("Web server closed")