diff options
Diffstat (limited to 'item')
-rw-r--r-- | item/item_router.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/item/item_router.go b/item/item_router.go new file mode 100644 index 0000000..b10c986 --- /dev/null +++ b/item/item_router.go @@ -0,0 +1,26 @@ +package item + +import ( + "github.com/gin-gonic/gin" + "github.com/MikunoNaka/OpenBills-lib/item" + "log" + "net/http" +) + + +func Routes(route *gin.Engine) { + i := route.Group("/item") + { + i.POST("/", func(ctx *gin.Context) { + var x item.Item + ctx.Bind(&x) + err := x.Save() + if err != nil { + ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + } + + log.Println("Added new item to database: ", x.Name) + ctx.JSON(http.StatusOK, nil) + }) + } +} |