package admin import ( "net/http" "os" "path/filepath" ) func (s *AdminServer) handleDashboard(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { http.Error(w, "method not allowed", http.StatusMethodNotAllowed) return } countYAML := func(subdir string) int { dir := filepath.Join(s.dataDir, subdir) n := 0 filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error { if err != nil || d.IsDir() { return nil } if filepath.Ext(d.Name()) == ".yaml" { n++ } return nil }) return n } dashboard := map[string]any{ "roomCount": countYAML("rooms"), "itemCount": countYAML("items"), "objectCount": countYAML("objects"), "mobCount": countYAML("mobs"), "playerCount": countYAML("players/characters"), "accountCount": countYAML("players/accounts"), } writeJSON(w, dashboard) }