1
0

Fixed a bug where a struct would have old values in it

This commit is contained in:
konrad
2018-07-14 17:46:01 +02:00
committed by kolaente
parent a5552b8f9d
commit bcbd415529
4 changed files with 8 additions and 20 deletions

View File

@ -4,10 +4,15 @@ import (
"git.kolaente.de/konrad/list/models"
"github.com/labstack/echo"
"net/http"
"reflect"
)
// UpdateWeb is the webhandler to update an object
func (c *WebHandler) UpdateWeb(ctx echo.Context) error {
// Re-initialize our model
p := reflect.ValueOf(c.CObject).Elem()
p.Set(reflect.Zero(p.Type()))
// Get the object
if err := ctx.Bind(&c.CObject); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "No or invalid model provided.")