aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-18 19:07:37 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-18 19:25:30 -0800
commitd466cf8a4717e09cef6d8b3c39c06e0935dafba7 (patch)
tree79d28e0076a302786e2f592798f8a8752af0815a /api
parent082089e427df8e34a366684f71f35ed700ec5d04 (diff)
downloadneko-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.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/api/api.go b/api/api.go
index 16e8dd6..8785cd4 100644
--- a/api/api.go
+++ b/api/api.go
@@ -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)