CRUD helper now returns directly the target struct filled with data instead of a sub objectq

This commit is contained in:
kolaente 2018-07-08 13:26:43 +02:00
parent 490f32d46b
commit 0c5ed914e0
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 2 additions and 4 deletions

View File

@ -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)
}

View File

@ -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{},