Exemple #1
0
// POST /tasks
func addTask(c *girl.Context) girl.View {
	task := model.Task{
		UserId:  c.GetNumParam("user_id"),
		Title:   c.GetParam("title"),
		Content: c.GetParam("content"),
		Active:  true,
	}

	task.Save()
	return c.RenderJSON(task)
}
Exemple #2
0
// PUT /tasks/:id
func updateTask(c *girl.Context) girl.View {
	active := true
	if c.GetParam("active") != "0" {
		active = false
	}
	task := model.Task{
		Id:      c.GetNumParam("id"),
		UserId:  c.GetNumParam("user_id"),
		Title:   c.GetParam("title"),
		Content: c.GetParam("content"),
		Active:  active,
	}

	task.Save()
	return c.RenderJSON(task)
}
Exemple #3
0
// GET /tasks/:id
func getTask(c *girl.Context) girl.View {
	id, _ := strconv.Atoi(c.GetParam("id"))

	task := model.FindTask(id)
	return c.Render("task", task)
}