コード例 #1
0
func CreateTodo(c *gin.Context) {
	var todo models.Todo

	if err := c.BindJSON(&todo); err != nil {
		return
	}

	if err := todo.Create(app.GetDB(c)); err != nil {
		utils.AbortWithPublicError(c, http.StatusInternalServerError, err, "Couldn't create the todo")
		return
	}

	c.JSON(http.StatusCreated, todo)
}