35 lines
642 B
Go
35 lines
642 B
Go
package main
|
|
|
|
import (
|
|
"github.com/gin-contrib/cors"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type PostResult struct {
|
|
Name string
|
|
Comment string
|
|
Timestamp string
|
|
Inventory []Drink
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
// Saving the whole POST result in this variable for later use
|
|
var postResult = PostResult{}
|
|
|
|
func main() {
|
|
router := gin.Default()
|
|
router.Use(cors.Default())
|
|
|
|
router.POST("/drinks", postDrinks)
|
|
|
|
router.Run("0.0.0.0:8151")
|
|
}
|