diff options
Diffstat (limited to 'item')
-rw-r--r-- | item/item_router.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/item/item_router.go b/item/item_router.go index b10c986..1af42c0 100644 --- a/item/item_router.go +++ b/item/item_router.go @@ -17,10 +17,24 @@ func Routes(route *gin.Engine) { err := x.Save() if err != nil { ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + log.Printf("ERROR: Failed to add new item \"%s\": %v", x.Name, err.Error()) } log.Println("Added new item to database: ", x.Name) ctx.JSON(http.StatusOK, nil) }) + + i.DELETE("/", func(ctx *gin.Context) { + var x item.Item + ctx.Bind(&x) + err := x.Delete() + if err != nil { + ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + log.Printf("ERROR: Failed to delete item \"%s\": %v", x.Name, err.Error()) + } + + log.Println("Deleted item: ", x.Name) + ctx.JSON(http.StatusOK, nil) + }) } } |