Added auth

This commit is contained in:
Pijus Kamandulis
2025-07-04 21:05:28 +03:00
parent b3c89a01d0
commit ef247fc843
13 changed files with 297 additions and 80 deletions

View File

@@ -1,7 +1,6 @@
package web
import (
"html/template"
"net/http"
"pool-stats/database"
"pool-stats/models"
@@ -9,19 +8,14 @@ import (
)
type SharePageData struct {
PageDataBase
Shares []models.ShareLog
Page int
HasMore bool
}
func (ws *WebServer) SharesHandler(w http.ResponseWriter, r *http.Request) {
tmpl, err := template.Must(ws.templates.Clone()).ParseFiles("templates/shares.html")
if err != nil {
http.Error(w, "Failed to parse template", 500)
println("Error parsing template:", err.Error())
return
}
entriesPerPage := 10
page := r.URL.Query().Get("page")
if page == "" {
@@ -46,8 +40,6 @@ func (ws *WebServer) SharesHandler(w http.ResponseWriter, r *http.Request) {
Page: offset/entriesPerPage + 1,
HasMore: len(shareLogs) == entriesPerPage,
}
if err := tmpl.ExecuteTemplate(w, "shares.html", data); err != nil {
http.Error(w, "Failed to render template", 500)
return
}
ws.renderTemplate(w, r, "templates/shares.html", &data)
}