From 0c5ed914e0a22e32a0c5a49cfb718f7d972bc4c8 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 8 Jul 2018 13:26:43 +0200 Subject: [PATCH] CRUD helper now returns directly the target struct filled with data instead of a sub objectq --- routes/api/v1/CRUD_helper.go | 5 ++--- routes/routes.go | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/routes/api/v1/CRUD_helper.go b/routes/api/v1/CRUD_helper.go index 37c9b607..e8048d3c 100644 --- a/routes/api/v1/CRUD_helper.go +++ b/routes/api/v1/CRUD_helper.go @@ -28,7 +28,7 @@ func (d *DefaultCRUD) Read(id int64) (err error) { // This does web stuff, aka returns json etc. Uses DefaultCRUD Methods to get the data type CRUDWebHandler struct { - CObject CRUD + CObject *DefaultCRUD } // This does json, handles the request @@ -52,6 +52,5 @@ func (c *CRUDWebHandler) ReadOneWeb(ctx echo.Context) error { return ctx.JSON(http.StatusInternalServerError, models.Message{"An error occured."}) } - // TODO how can we return c.CObject.Targetdirectly? - return ctx.JSON(http.StatusOK, c.CObject) + return ctx.JSON(http.StatusOK, c.CObject.Target) } diff --git a/routes/routes.go b/routes/routes.go index 8e9a2f9a..a726df01 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -84,7 +84,6 @@ func RegisterRoutes(e *echo.Echo) { a.POST("/tokenTest", apiv1.CheckToken) a.GET("/lists", apiv1.GetListsByUser) - //a.GET("/lists/:id", apiv1.GetListByID) listHandler := &apiv1.CRUDWebHandler{ CObject: &apiv1.DefaultCRUD{ Target: &models.List{},