tasks can be marked as finished
This commit is contained in:
parent
5e63fc1e38
commit
3bf957ee30
3 changed files with 44 additions and 7 deletions
|
@ -55,10 +55,26 @@ func (wp *Webpage) defineRoutes() {
|
|||
c.JSON(200, gin.H{"task": task})
|
||||
}
|
||||
})
|
||||
tasks.DELETE(":id", func(c *gin.Context) {
|
||||
tasks.DELETE("", func(c *gin.Context) {
|
||||
if wp.isLoggedInMiddleware(c) {
|
||||
id := c.Param("id")
|
||||
wp.Database.DeleteTask(id)
|
||||
id := c.Query("id")
|
||||
ok := wp.Database.DeleteTask(id)
|
||||
if !ok {
|
||||
c.JSON(500, gin.H{"message": "cannot delete task"})
|
||||
return
|
||||
}
|
||||
c.JSON(200, gin.H{"message": "success"})
|
||||
}
|
||||
})
|
||||
tasks.PUT("", func(c *gin.Context) {
|
||||
if wp.isLoggedInMiddleware(c) {
|
||||
id := c.Query("id")
|
||||
done := c.Query("done")
|
||||
ok := wp.Database.UpdateTask(id, done)
|
||||
if !ok {
|
||||
c.JSON(500, gin.H{"message": "cannot update task"})
|
||||
return
|
||||
}
|
||||
c.JSON(200, gin.H{"message": "success"})
|
||||
}
|
||||
})
|
||||
|
|
Reference in a new issue