Refactor pool-stats into modular code structure

This commit is contained in:
openhands
2025-05-27 18:17:02 +00:00
parent 0a53686351
commit 7b9f0d0af7
9 changed files with 348 additions and 379 deletions

20
web/handlers.go Normal file
View File

@@ -0,0 +1,20 @@
package web
import (
"html/template"
"net/http"
"pool-stats/database"
"pool-stats/stats"
)
func (h database.Handlers) IndexHandler(w http.ResponseWriter, r *http.Request) {
shareStats, err := stats.GetStats(h.DB)
if err != nil {
http.Error(w, "Failed to load stats", 500)
return
}
tmpl := template.Must(template.ParseFiles("templates/index.html"))
tmpl.Execute(w, shareStats)
}