This commit is contained in:
Miki 2023-12-06 11:00:38 +01:00
parent 555e7b85ea
commit 34ecc9f036
17 changed files with 70 additions and 57 deletions

37
backend/setup.go Normal file
View file

@ -0,0 +1,37 @@
package main
import (
"log"
"net/http"
"github.com/gin-gonic/gin"
)
type Surfer struct {
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
Color string `json:"color"`
}
type Heat struct {
Name string `json:"name"`
Category string `json:"category"`
Number string `json:"number"`
Surfers []Surfer `json:"surfers"`
}
func (w *Webapp) SetupHeat(c *gin.Context) {
var heat Heat
err := c.ShouldBind(&heat)
if err != nil {
log.Printf("req error: %+v", err)
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
log.Printf("heat: %+v", heat)
c.JSON(http.StatusOK, gin.H{"status": "added"})
}