From 444f10ea7e2d1ff9b44a237e771f7253bbc7099e Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sat, 3 May 2025 12:16:43 +0300 Subject: [PATCH] feat: retrieve session and room in HandleShowColor --- handlers/elements.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/handlers/elements.go b/handlers/elements.go index 4b91113..cc5f90a 100644 --- a/handlers/elements.go +++ b/handlers/elements.go @@ -28,6 +28,16 @@ func HandleHideCreateForm(w http.ResponseWriter, r *http.Request) { func HandleShowColor(w http.ResponseWriter, r *http.Request) { word := r.URL.Query().Get("word") + ctx := r.Context() + session, ok := ctx.Value(models.CtxSessionKey).(models.Session) + if !ok { + // trying to get color without a session -> error + } + // get room by room-id + room, err := getRoomByID(session.CurrentRoom) + if err != nil { + // handle err; ai! + } color, exists := roundWords[word] log.Debug("got show-color request", "word", word, "color", color) if !exists {