diff options
Diffstat (limited to 'internal/handlers')
-rw-r--r-- | internal/handlers/main.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/internal/handlers/main.go b/internal/handlers/main.go index 41ff85f..4aa8eca 100644 --- a/internal/handlers/main.go +++ b/internal/handlers/main.go @@ -154,11 +154,22 @@ func (h *Handlers) renderQuestion(w http.ResponseWriter, question *models.Questi } func (h *Handlers) MainPage(w http.ResponseWriter, r *http.Request) { - question, err := h.repo.DBGetQuestion("1") + ubungs, err := h.repo.DBGetFirst10MixedUbungs() if err != nil { - h.log.Error("failed to get question", "error", err) - abortWithError(w, "Question not found") + h.log.Error("failed to get mixed ubungs", "error", err) + abortWithError(w, "Failed to load exercises") return } - h.renderQuestion(w, question) + + tmpl, err := template.ParseGlob("components/*.html") + if err != nil { + abortWithError(w, err.Error()) + return + } + + w.Header().Set("Content-Type", "text/html") + err = tmpl.ExecuteTemplate(w, "main", ubungs) + if err != nil { + h.log.Error("failed to render template", "error", err) + } } |