1
0
Fork 0
forked from Mirrors/gomuks

server: add config option to enable pprof endpoints

This commit is contained in:
Tulir Asokan 2024-10-15 02:19:21 +03:00
parent 08bea53cf1
commit 038e62120b
2 changed files with 9 additions and 4 deletions

View file

@ -36,10 +36,11 @@ type Config struct {
}
type WebConfig struct {
ListenAddress string `yaml:"listen_address"`
Username string `yaml:"username"`
PasswordHash string `yaml:"password_hash"`
TokenKey string `yaml:"token_key"`
ListenAddress string `yaml:"listen_address"`
Username string `yaml:"username"`
PasswordHash string `yaml:"password_hash"`
TokenKey string `yaml:"token_key"`
DebugEndpoints bool `yaml:"debug_endpoints"`
}
var defaultConfig = Config{

View file

@ -24,6 +24,7 @@ import (
"errors"
"io/fs"
"net/http"
_ "net/http/pprof"
"strings"
"time"
@ -52,6 +53,9 @@ func (gmx *Gomuks) StartServer() {
gmx.AuthMiddleware,
)
router := http.NewServeMux()
if gmx.Config.Web.DebugEndpoints {
router.Handle("/debug/", http.DefaultServeMux)
}
router.Handle("/_gomuks/", apiHandler)
if frontend, err := fs.Sub(web.Frontend, "dist"); err != nil {
gmx.Log.Warn().Msg("Frontend not found")