1
0

Added method to delete a list

This commit is contained in:
konrad
2018-06-12 18:17:21 +02:00
committed by kolaente
parent 853fb2a2b7
commit dcb046665f
4 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package v1
import (
"github.com/labstack/echo"
"strconv"
"net/http"
"git.kolaente.de/konrad/list/models"
)
func DeleteListByID(c echo.Context) error {
// Check if we have our ID
id := c.Param("id")
// Make int
itemID, err := strconv.ParseInt(id, 10, 64)
if err != nil {
return c.JSON(http.StatusBadRequest, models.Message{"Invalid ID."})
}
err = models.DeleteListByID(itemID)
if err != nil {
return c.JSON(http.StatusInternalServerError, models.Message{"An error occured."})
}
return c.JSON(http.StatusOK, models.Message{"The list was deleted with success."})
}