Added auth
This commit is contained in:
@@ -1,24 +1,18 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
"pool-stats/database"
|
||||
"pool-stats/models"
|
||||
)
|
||||
|
||||
type TopSharesPageData struct {
|
||||
PageDataBase
|
||||
|
||||
Shares []models.ShareLog
|
||||
}
|
||||
|
||||
func (ws *WebServer) TopSharesHandler(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl, err := template.Must(ws.templates.Clone()).ParseFiles("templates/top_shares.html")
|
||||
if err != nil {
|
||||
http.Error(w, "Failed to parse template", 500)
|
||||
println("Error parsing template:", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
topShares := database.ListTopShares(ws.db)
|
||||
if topShares == nil {
|
||||
http.Error(w, "Failed to load top shares", 500)
|
||||
@@ -28,8 +22,6 @@ func (ws *WebServer) TopSharesHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := TopSharesPageData{
|
||||
Shares: topShares,
|
||||
}
|
||||
if err := tmpl.ExecuteTemplate(w, "top_shares.html", data); err != nil {
|
||||
http.Error(w, "Failed to render template", 500)
|
||||
return
|
||||
}
|
||||
|
||||
ws.renderTemplate(w, r, "templates/top_shares.html", &data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user