mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
server: add config option to enable pprof endpoints
This commit is contained in:
parent
08bea53cf1
commit
038e62120b
2 changed files with 9 additions and 4 deletions
|
@ -36,10 +36,11 @@ type Config struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebConfig struct {
|
type WebConfig struct {
|
||||||
ListenAddress string `yaml:"listen_address"`
|
ListenAddress string `yaml:"listen_address"`
|
||||||
Username string `yaml:"username"`
|
Username string `yaml:"username"`
|
||||||
PasswordHash string `yaml:"password_hash"`
|
PasswordHash string `yaml:"password_hash"`
|
||||||
TokenKey string `yaml:"token_key"`
|
TokenKey string `yaml:"token_key"`
|
||||||
|
DebugEndpoints bool `yaml:"debug_endpoints"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultConfig = Config{
|
var defaultConfig = Config{
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
_ "net/http/pprof"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -52,6 +53,9 @@ func (gmx *Gomuks) StartServer() {
|
||||||
gmx.AuthMiddleware,
|
gmx.AuthMiddleware,
|
||||||
)
|
)
|
||||||
router := http.NewServeMux()
|
router := http.NewServeMux()
|
||||||
|
if gmx.Config.Web.DebugEndpoints {
|
||||||
|
router.Handle("/debug/", http.DefaultServeMux)
|
||||||
|
}
|
||||||
router.Handle("/_gomuks/", apiHandler)
|
router.Handle("/_gomuks/", apiHandler)
|
||||||
if frontend, err := fs.Sub(web.Frontend, "dist"); err != nil {
|
if frontend, err := fs.Sub(web.Frontend, "dist"); err != nil {
|
||||||
gmx.Log.Warn().Msg("Frontend not found")
|
gmx.Log.Warn().Msg("Frontend not found")
|
||||||
|
|
Loading…
Add table
Reference in a new issue