Added lists view
This commit is contained in:
parent
b841ec121b
commit
125f0ba230
3 changed files with 44 additions and 0 deletions
22
routes/api/v1/lists_list.go
Normal file
22
routes/api/v1/lists_list.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo"
|
||||
"git.kolaente.de/konrad/list/models"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetListsByUser(c echo.Context) error {
|
||||
|
||||
currentUser, err := models.GetCurrentUser(c)
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, models.Message{"Could not determine the current user."})
|
||||
}
|
||||
|
||||
allLists, err := models.GetListsByUser(¤tUser)
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, models.Message{"Could not get lists."})
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, allLists)
|
||||
}
|
||||
Reference in a new issue