From 194e66b403fd6cb101707c26908c1bc6d81a6555 Mon Sep 17 00:00:00 2001 From: "Grail Finder (aider)" Date: Sat, 29 Mar 2025 14:44:08 +0300 Subject: feat: add answer handler with question ID tracking --- internal/handlers/main.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'internal/handlers') diff --git a/internal/handlers/main.go b/internal/handlers/main.go index 3f2e1b2..1f3f740 100644 --- a/internal/handlers/main.go +++ b/internal/handlers/main.go @@ -37,6 +37,23 @@ func (h *Handlers) Ping(w http.ResponseWriter, r *http.Request) { w.Write([]byte("pong")) } +func (h *Handlers) HandleAnswer(w http.ResponseWriter, r *http.Request) { + if err := r.ParseForm(); err != nil { + abortWithError(w, "Invalid form data") + return + } + + selectedIndex := r.FormValue("selected") + questionID := r.FormValue("question_id") + h.log.Info("answer received", + "selected", selectedIndex, + "question_id", questionID) + + // TODO: Add actual answer validation logic here + // For now just return the same question + h.MainPage(w, r) +} + func (h *Handlers) MainPage(w http.ResponseWriter, r *http.Request) { tmpl, err := template.ParseGlob("components/*.html") if err != nil { -- cgit v1.2.3