package groups import ( "git.macaw.me/inhosin/subhub/data" "git.macaw.me/inhosin/subhub/data/models" "github.com/gin-gonic/gin" "net/http" ) type createGroupRequest struct { Name string `json:"name"` Status string `json:"status"` } type createGroupResponse struct { Slug string `json:"slug"` } // Create adds an group to the database func Create(c *gin.Context) { var body createGroupRequest _ = c.BindJSON(&body) slug, err := models.PutGroup(data.GetDB(), body.Name, body.Status) if err != nil { c.String(http.StatusInternalServerError, err.Error()) return } resp := createGroupResponse{Slug: slug} c.JSON(http.StatusOK, resp) }