I am going through your Gin book and I reckon we loose the id when updating the pizza recipe in chapter02.
In the book example the PUT request does not include the ID and thus the ID is going to be empty in the resulting id filed.
Overwriting the ID with what came in from PUT solves this.
+++ b/chapter02/main.go
@@ -102,11 +102,11 @@ func UpdateRecipeHandler(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
-
+ recipe.ID = id
index := -1
for i := 0; i < len(recipes); i++ {
I am going through your Gin book and I reckon we loose the id when updating the pizza recipe in chapter02.
In the book example the PUT request does not include the ID and thus the ID is going to be empty in the resulting id filed.
Overwriting the ID with what came in from PUT solves this.