some stuff

This commit is contained in:
2022-01-25 09:17:11 +01:00
parent 892307185a
commit 43d05ce727
2 changed files with 13 additions and 3 deletions

11
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,11 @@
{
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "."
}
]
}

View File

@@ -1,6 +1,7 @@
package api
import (
"log"
"net/http"
"strconv"
@@ -60,12 +61,11 @@ func RegisterRoutes(router *gin.RouterGroup, prov types.IPersitenceProvider) {
id, err := strconv.Atoi(c.Param("id"))
if err != nil {
c.String(http.StatusBadRequest, err.Error())
return
}
log.Println(id)
item, err := prov.GetItem(id)
if err != nil {
c.String(http.StatusInternalServerError, err.Error())
return
}
c.JSON(http.StatusOK, ItemToDTO(item))
})
@@ -88,7 +88,6 @@ func RegisterRoutes(router *gin.RouterGroup, prov types.IPersitenceProvider) {
}
if err := c.BindJSON(&item); err != nil {
c.String(http.StatusBadRequest, err.Error())
return
}
prov.CreateItem(ItemDTO{message: item.message})
c.Status(200)