diff options
| author | Adam Mathes <adam@adammathes.com> | 2026-02-18 19:07:37 -0800 |
|---|---|---|
| committer | Adam Mathes <adam@adammathes.com> | 2026-02-18 19:25:30 -0800 |
| commit | d466cf8a4717e09cef6d8b3c39c06e0935dafba7 (patch) | |
| tree | 79d28e0076a302786e2f592798f8a8752af0815a /api | |
| parent | 082089e427df8e34a366684f71f35ed700ec5d04 (diff) | |
| download | neko-d466cf8a4717e09cef6d8b3c39c06e0935dafba7.tar.gz neko-d466cf8a4717e09cef6d8b3c39c06e0935dafba7.tar.bz2 neko-d466cf8a4717e09cef6d8b3c39c06e0935dafba7.zip | |
Fix mark-as-read regression and add debugging tools
Diffstat (limited to 'api')
| -rw-r--r-- | api/api.go | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -108,18 +108,22 @@ func (s *Server) HandleItem(w http.ResponseWriter, r *http.Request) { switch r.Method { case http.MethodPut: - var i item.Item - if err := json.NewDecoder(r.Body).Decode(&i); err != nil { - jsonError(w, "invalid json", http.StatusBadRequest) + i := item.ItemById(id) + if i == nil { + jsonError(w, "item not found", http.StatusNotFound) return } - if i.Id == 0 { - i.Id = id + + if err := json.NewDecoder(r.Body).Decode(i); err != nil { + jsonError(w, "invalid json", http.StatusBadRequest) + return } + if i.Id != id { jsonError(w, "id mismatch", http.StatusBadRequest) return } + i.Save() jsonResponse(w, i) |
