forked from gobitfly/eth2-beaconchain-explorer
/
graffitiwall.go
34 lines (25 loc) · 992 Bytes
/
graffitiwall.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package handlers
import (
"eth2-exporter/db"
"eth2-exporter/templates"
"eth2-exporter/types"
"net/http"
)
func Graffitiwall(w http.ResponseWriter, r *http.Request) {
templateFiles := append(layoutTemplateFiles, "graffitiwall.html")
var graffitiwallTemplate = templates.GetTemplate(templateFiles...)
var err error
w.Header().Set("Content-Type", "text/html")
var graffitiwallData []*types.GraffitiwallData
err = db.ReaderDb.Select(&graffitiwallData, "select x, y, color, slot, validator from graffitiwall")
if err != nil {
logger.Errorf("error retrieving block tree data: %v", err)
http.Error(w, "Internal server error", http.StatusServiceUnavailable)
return
}
data := InitPageData(w, r, "more", "/graffitiwall", "Graffitiwall", templateFiles)
data.Data = graffitiwallData
if handleTemplateError(w, r, "graffitiwall.go", "Graffitiwall", "", graffitiwallTemplate.ExecuteTemplate(w, "layout", data)) != nil {
return // an error has occurred and was processed
}
}