1
0

implemented team create method

This commit is contained in:
konrad
2018-07-14 17:34:59 +02:00
committed by kolaente
parent 376c649a12
commit e1c58843e9
8 changed files with 108 additions and 22 deletions

View File

@ -4,10 +4,14 @@ import (
"git.kolaente.de/konrad/list/models"
"github.com/labstack/echo"
"net/http"
"fmt"
)
// CreateWeb is the handler to create an object
func (c *WebHandler) CreateWeb(ctx echo.Context) error {
// Re-initialize our model
c.CObject.Empty()
// Get the object
if err := ctx.Bind(&c.CObject); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "No or invalid model provided.")
@ -53,6 +57,8 @@ func (c *WebHandler) CreateWeb(ctx echo.Context) error {
return echo.NewHTTPError(http.StatusNotFound, "The namespace name cannot be empty.")
}
fmt.Println(err)
return echo.NewHTTPError(http.StatusInternalServerError)
}

View File

@ -112,4 +112,13 @@ func RegisterRoutes(e *echo.Echo) {
a.POST("/namespaces/:id", namespaceHandler.UpdateWeb)
a.DELETE("/namespaces/:id", namespaceHandler.DeleteWeb)
a.GET("/namespaces/:id/lists", apiv1.GetListsByNamespaceID)
teamHandler := &crud.WebHandler{
CObject: &models.Team{},
}
a.GET("/teams", teamHandler.ReadAllWeb)
a.GET("/teams/:id", teamHandler.ReadOneWeb)
a.PUT("/teams", teamHandler.CreateWeb)
a.POST("/teams/:id", teamHandler.UpdateWeb)
a.POST("/teams/:id", teamHandler.DeleteWeb)
}