From 96441a431eaca60b1b798e997608812c8be76598 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sat, 5 Apr 2025 17:56:01 +0300 Subject: feat: update question template and simplify handler logic --- internal/handlers/main.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'internal/handlers') diff --git a/internal/handlers/main.go b/internal/handlers/main.go index 97a54cd..4717f3c 100644 --- a/internal/handlers/main.go +++ b/internal/handlers/main.go @@ -13,9 +13,9 @@ import ( // Handlers structure type Handlers struct { - cfg config.Config - log *slog.Logger - repo repos.FullRepo + cfg config.Config + log *slog.Logger + repo repos.FullRepo } // NewHandlers constructor @@ -134,10 +134,7 @@ func (h *Handlers) renderQuestion(w http.ResponseWriter, question *models.Questi *models.Question } - err = tmpl.ExecuteTemplate(w, "main", &TemplateData{ - Question: question, - ShowNext: h.showNext, - }) + err = tmpl.ExecuteTemplate(w, "main", question) if err != nil { h.log.Error("failed to render template", "error", err) } @@ -157,6 +154,5 @@ func (h *Handlers) MainPage(w http.ResponseWriter, r *http.Request) { abortWithError(w, "Question not found") return } - h.renderQuestion(w, question) } -- cgit v1.2.3