implemented get all namespaces via interface
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"git.kolaente.de/konrad/list/models"
|
||||
"github.com/labstack/echo"
|
||||
"net/http"
|
||||
)
|
||||
@ -21,15 +20,18 @@ func GetAllNamespacesByCurrentUser(c echo.Context) error {
|
||||
// "500":
|
||||
// "$ref": "#/responses/Message"
|
||||
|
||||
user, err := models.GetCurrentUser(c)
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, models.Message{"Could not get the current user."})
|
||||
}
|
||||
return echo.NewHTTPError(http.StatusNotImplemented)
|
||||
/*
|
||||
|
||||
namespaces, err := models.GetAllNamespacesByUserID(user.ID)
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, models.Message{"Could not get namespaces."})
|
||||
}
|
||||
user, err := models.GetCurrentUser(c)
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, models.Message{"Could not get the current user."})
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, namespaces)
|
||||
namespaces, err := models.GetAllNamespacesByUserID(user.ID)
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, models.Message{"Could not get namespaces."})
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, namespaces)*/
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package crud
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.kolaente.de/konrad/list/models"
|
||||
"github.com/labstack/echo"
|
||||
"net/http"
|
||||
@ -16,7 +15,6 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
|
||||
|
||||
lists, err := c.CObject.ReadAll(¤tUser)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return ctx.JSON(http.StatusInternalServerError, models.Message{"Could not get."})
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,10 @@ func RegisterRoutes(e *echo.Echo) {
|
||||
a.DELETE("/items/:id", itemHandler.DeleteWeb)
|
||||
a.POST("/items/:id", itemHandler.UpdateWeb)
|
||||
|
||||
a.GET("/namespaces", apiv1.GetAllNamespacesByCurrentUser)
|
||||
namespaceHandler := &crud.WebHandler{
|
||||
CObject: &models.Namespace{},
|
||||
}
|
||||
a.GET("/namespaces", namespaceHandler.ReadAllWeb)
|
||||
a.PUT("/namespaces", apiv1.AddNamespace)
|
||||
a.GET("/namespaces/:id", apiv1.ShowNamespace)
|
||||
a.POST("/namespaces/:id", apiv1.UpdateNamespace)
|
||||
|
Reference in New Issue
Block a user