diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 13f35ff..5d97731 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -192,10 +192,10 @@ func (h *GuestbookHandlers) Update(w http.ResponseWriter, r *http.Request) { } if strings.HasSuffix(r.URL.Path, "reply") { - rp := guestbook.Reply{ID: entryID} + rp := guestbook.Reply{} json.NewDecoder(r.Body).Decode(&rp) - isCreated, err := h.db.UpdateReply(&rp) + isCreated, err := h.db.UpdateReply(entryID, &rp) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -208,10 +208,10 @@ func (h *GuestbookHandlers) Update(w http.ResponseWriter, r *http.Request) { w.Header().Add("Content-Type", "application/json") json.NewEncoder(w).Encode(&rp) } else { - et := guestbook.Entry{ID: entryID} + et := guestbook.Entry{} json.NewDecoder(r.Body).Decode(&et) - isCreated, err := h.db.UpdateEntry(&et) + isCreated, err := h.db.UpdateEntry(entryID, &et) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return