diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/client_router.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/client/client_router.go b/client/client_router.go index 8b16f2e..a36ec48 100644 --- a/client/client_router.go +++ b/client/client_router.go @@ -16,10 +16,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 client \"%s\": %v", x.Name, err.Error()) } log.Println("Added new client to database: ", x.Name) ctx.JSON(http.StatusOK, nil) }) + + c.DELETE("/", func(ctx *gin.Context) { + var x client.Client + ctx.Bind(&x) + err := x.Delete() + if err != nil { + ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + log.Printf("ERROR: Failed to delete client \"%s\": %v", x.Name, err.Error()) + } + + log.Println("Deleted client: ", x.Name) + ctx.JSON(http.StatusOK, nil) + }) } } |