spartacus-inventur-backend/main.go

35 lines
642 B
Go
Raw Normal View History

2023-01-29 00:43:52 +01:00
package main
import (
"github.com/gin-contrib/cors"
2023-01-29 00:43:52 +01:00
"github.com/gin-gonic/gin"
)
type PostResult struct {
Name string
Comment string
Timestamp string
Inventory []Drink
2023-01-29 00:43:52 +01:00
}
type Drink struct {
// Don't use this field, it's just meaningful for the frontend
InventoryStartedAt string `json:"-"`
Name string
Type string
AmountContainers int
AmountBottles int
2023-01-29 00:43:52 +01:00
}
// Saving the whole POST result in this variable for later use
var postResult = PostResult{}
2023-01-29 00:43:52 +01:00
func main() {
router := gin.Default()
router.Use(cors.Default())
2023-01-29 00:43:52 +01:00
router.POST("/drinks", postDrinks)
2023-01-29 00:43:52 +01:00
router.Run("0.0.0.0:8151")
2023-01-29 00:43:52 +01:00
}