33 lines
783 B
Go
33 lines
783 B
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"abuse_registration_poc/internal/models"
|
|
)
|
|
|
|
func (h *Handler) Index(writer http.ResponseWriter, request *http.Request) {
|
|
_, _, nextReset := h.store.Snapshot()
|
|
data := struct {
|
|
Version string
|
|
NextReset string
|
|
Locations []string
|
|
Categories []string
|
|
Genders []string
|
|
Statuses []string
|
|
}{
|
|
Version: h.version,
|
|
NextReset: nextReset.Format(time.RFC3339),
|
|
Locations: models.FaroeLocations,
|
|
Categories: models.AbuseCategories,
|
|
Genders: models.Genders,
|
|
Statuses: models.Statuses,
|
|
}
|
|
|
|
writer.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
if err := h.index.ExecuteTemplate(writer, "index.html", data); err != nil {
|
|
http.Error(writer, err.Error(), http.StatusInternalServerError)
|
|
}
|
|
}
|