delete in the backend

This commit is contained in:
Florian Hoss 2022-04-06 21:11:27 +02:00
parent f73f862bcf
commit ba6e5a9c17
3 changed files with 22 additions and 1 deletions

View file

@ -55,6 +55,13 @@ func (wp *Webpage) defineRoutes() {
c.JSON(200, gin.H{"task": task})
}
})
tasks.DELETE(":id", func(c *gin.Context) {
if wp.isLoggedInMiddleware(c) {
id := c.Param("id")
wp.Database.DeleteTask(id)
c.JSON(200, gin.H{"message": "success", "id": id})
}
})
}
auth := wp.Router.Group("/auth")