refactor-code-modules (#1)
Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: Pijus Kamandulis <pkpjuklas@gmail.com> Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
25
web/handlers.go
Normal file
25
web/handlers.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"pool-stats/stats"
|
||||
|
||||
"github.com/ostafen/clover/v2"
|
||||
)
|
||||
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
||||
tmpl := template.Must(template.ParseFiles("templates/index.html"))
|
||||
tmpl.Execute(w, shareStats)
|
||||
}
|
||||
Reference in New Issue
Block a user