Example #1
0
File: app.go Project: udbmnm/girl
// TODO not used
func Auth(c *girl.Context) girl.View {
	ck, _ := c.Request.Cookie("user_id")
	if ck == nil {
		return c.Redirect("/login")
	}
	return nil
}
Example #2
0
File: app.go Project: udbmnm/girl
// 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)
}
Example #3
0
File: app.go Project: udbmnm/girl
// DELETE /tasks/:id
func deleteTask(c *girl.Context) girl.View {
	model.DeleteTask(c.GetNumParam("id"))
	return c.RenderText("success")
}
Example #4
0
File: app.go Project: udbmnm/girl
// 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)
}
Example #5
0
File: app.go Project: udbmnm/girl
// 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)
}
Example #6
0
File: app.go Project: udbmnm/girl
// GET /tasks
func getTasks(c *girl.Context) girl.View {
	tasks := model.FindTasks()
	return c.RenderJSON(tasks)
}
Example #7
0
File: app.go Project: udbmnm/girl
// GET /
func index(c *girl.Context) girl.View {
	return c.Render("index", model.User{Name: model.GetUser()})
}
Example #8
0
File: hello.go Project: udbmnm/girl
func Index(c *girl.Context) girl.View {
	return c.RenderText("hello world")
}