add debug endpoint

This commit is contained in:
a 2022-10-25 22:43:00 -05:00
parent e72d1a17b2
commit c12b90f0cd
1 changed files with 4 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import (
"gfx.cafe/open/4bytes/triemap"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/ledgerwatch/erigon/common/debug"
"github.com/wmitsuda/otterscan/cmd/otter/cli/httpcfg"
"github.com/wmitsuda/otterscan/lib/resources"
)
@ -23,6 +24,9 @@ func RouteServer(r chi.Router, cfg httpcfg.HttpCfg) {
r.HandleFunc("/topic0/{hash}", triemap.HttpHandler(topics.Both))
r.Handle("/chains/{chainId}", http.FileServer(resources.ChainsServer))
r.Handle("/tokens/{chainId}/{address}/logo.png", http.FileServer(resources.AssetsServer))
r.HandleFunc("/memstats", func(w http.ResponseWriter, r *http.Request) {
debug.PrintMemStats(false)
})
r.HandleFunc("/config.json", func(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(map[string]any{
"erigonURL": cfg.OtsRpcDaemonUrl,