CRUD helper now returns directly the target struct filled with data instead of a sub objectq
This commit is contained in:
parent
490f32d46b
commit
0c5ed914e0
2 changed files with 2 additions and 4 deletions
|
@ -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
|
// This does web stuff, aka returns json etc. Uses DefaultCRUD Methods to get the data
|
||||||
type CRUDWebHandler struct {
|
type CRUDWebHandler struct {
|
||||||
CObject CRUD
|
CObject *DefaultCRUD
|
||||||
}
|
}
|
||||||
|
|
||||||
// This does json, handles the request
|
// 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."})
|
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.Target)
|
||||||
return ctx.JSON(http.StatusOK, c.CObject)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,6 @@ func RegisterRoutes(e *echo.Echo) {
|
||||||
a.POST("/tokenTest", apiv1.CheckToken)
|
a.POST("/tokenTest", apiv1.CheckToken)
|
||||||
|
|
||||||
a.GET("/lists", apiv1.GetListsByUser)
|
a.GET("/lists", apiv1.GetListsByUser)
|
||||||
//a.GET("/lists/:id", apiv1.GetListByID)
|
|
||||||
listHandler := &apiv1.CRUDWebHandler{
|
listHandler := &apiv1.CRUDWebHandler{
|
||||||
CObject: &apiv1.DefaultCRUD{
|
CObject: &apiv1.DefaultCRUD{
|
||||||
Target: &models.List{},
|
Target: &models.List{},
|
||||||
|
|
Loading…
Reference in a new issue