endpoint to get tasks
This commit is contained in:
parent
9e058e4f03
commit
712af41c28
5 changed files with 28 additions and 3 deletions
|
@ -25,6 +25,18 @@ func (wp *Webpage) defineRoutes() {
|
|||
c.HTML(http.StatusOK, "register.tmpl", gin.H{"title": "Register"})
|
||||
})
|
||||
}
|
||||
tasks := wp.Router.Group("/tasks")
|
||||
{
|
||||
tasks.GET("", func(c *gin.Context) {
|
||||
username := c.Request.Header.Get("username")
|
||||
if wp.Database.UserIsLoggedIn(username) {
|
||||
tasks := wp.Database.GetAllTasks()
|
||||
c.JSON(200, gin.H{"tasks": tasks})
|
||||
} else {
|
||||
c.JSON(401, gin.H{"message": "unauthorized"})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
auth := wp.Router.Group("/auth")
|
||||
{
|
||||
|
|
Reference in a new issue