34 lines
521 B
Go
34 lines
521 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"dev.sum7.eu/genofire/golang-lib/database"
|
|
|
|
"dev.sum7.eu/genofire/meetandeat/models"
|
|
)
|
|
|
|
func getPersonAll(c *gin.Context) {
|
|
list := []*models.Person{}
|
|
database.Read.Find(&list)
|
|
|
|
c.JSON(http.StatusOK, list)
|
|
}
|
|
|
|
func addPerson(c *gin.Context) {
|
|
var name string
|
|
if err := c.BindJSON(&name); err != nil {
|
|
c.JSON(http.StatusBadRequest, err.Error())
|
|
return
|
|
}
|
|
d := &models.Person{
|
|
Name: name,
|
|
}
|
|
|
|
database.Write.Save(d)
|
|
|
|
c.JSON(http.StatusOK, d)
|
|
}
|