From 53a4e67f7024d406f8f92a6e74dd742fece2768c Mon Sep 17 00:00:00 2001 From: Hein Date: Wed, 19 Nov 2025 14:24:39 +0200 Subject: [PATCH] Specifically call update if a ID was given. --- pkg/restheadspec/handler.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/restheadspec/handler.go b/pkg/restheadspec/handler.go index 3b6235b..a6d8fe4 100644 --- a/pkg/restheadspec/handler.go +++ b/pkg/restheadspec/handler.go @@ -7,6 +7,7 @@ import ( "net/http" "reflect" "runtime/debug" + "strconv" "strings" "github.com/bitechdev/ResolveSpec/pkg/common" @@ -133,9 +134,15 @@ func (h *Handler) Handle(w common.ResponseWriter, r common.Request, params map[s h.sendError(w, http.StatusBadRequest, "invalid_request", "Invalid request body", err) return } - h.handleCreate(ctx, w, data, options) + validId, _ := strconv.ParseInt(id, 10, 64) + if validId > 0 { + h.handleUpdate(ctx, w, id, nil, data, options) + } else { + h.handleCreate(ctx, w, data, options) + } case "PUT", "PATCH": // Update operation + body, err := r.Body() if err != nil { logger.Error("Failed to read request body: %v", err)