This commit is contained in:
Pijus Kamandulis
2025-05-27 21:29:23 +03:00
parent dfe65255fc
commit 5bfa8422ca
7 changed files with 38 additions and 38 deletions

View File

@@ -4,11 +4,16 @@ import (
"html/template"
"net/http"
"pool-stats/database"
"pool-stats/stats"
"github.com/ostafen/clover/v2"
)
func (h database.Handlers) IndexHandler(w http.ResponseWriter, r *http.Request) {
type Handlers struct {
DB *clover.DB
}
func (h 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)
@@ -17,4 +22,4 @@ func (h database.Handlers) IndexHandler(w http.ResponseWriter, r *http.Request)
tmpl := template.Must(template.ParseFiles("templates/index.html"))
tmpl.Execute(w, shareStats)
}
}