diff options
author | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-04-28 10:12:46 +0530 |
---|---|---|
committer | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-04-28 10:12:46 +0530 |
commit | 60f5d0cf22adc77b236f6c5a6e6aa2c7ff39ed77 (patch) | |
tree | 95b1902b7613fb9b1a7469499655fcfad8210aba /server/main.go | |
parent | 8187f8db90c5d301f9a8304fc954588167833695 (diff) |
implemented a small package to get items from sqlite db
Diffstat (limited to 'server/main.go')
-rw-r--r-- | server/main.go | 46 |
1 files changed, 2 insertions, 44 deletions
diff --git a/server/main.go b/server/main.go index 5eab33c..b514a31 100644 --- a/server/main.go +++ b/server/main.go @@ -12,23 +12,15 @@ package main import ( - "net/http" "github.com/gin-gonic/gin" "github.com/gin-gonic/contrib/static" + "net/http" // this handles all the database functions db "github.com/MikunoNaka/openbills/database" ) -type Item struct { - Model string - Desc string `json:"Description"` - Price float32 - HSN int -} - func main() { - db.SayHello() myRouter := gin.New() myRouter.Use(gin.Logger()) @@ -46,40 +38,6 @@ func main() { } func getAllItems(ctx *gin.Context) { - allItems := [6]Item{ - { - "Kisan Chair", - "Very Good Chair", - 100, - 9403, - }, { - "Supreme Chair", - "Even Better Chair", - 200, - 9403, - }, { - "Action Houseware", - "Not a chair", - 50, - 69, - }, { - "Coirfit Mattress", - "I wanna sleep", - 900, - 420, - }, { - "AVRO Chair", - "Formerly AVON lol", - 150, - 9403, - }, { - "Mystery Item", - "hehe hehehehe", - 1000, - 177013, - }, - } - ctx.Header("Content-Type", "application/json") - ctx.JSON(http.StatusOK, allItems) + ctx.JSON(http.StatusOK, db.GetAllItems()) } |