本文整理汇总了Golang中github.com/cgyy/girl.Context类的典型用法代码示例。如果您正苦于以下问题:Golang Context类的具体用法?Golang Context怎么用?Golang Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Context类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Auth
// 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
}
示例2: addTask
// 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)
}
示例3: deleteTask
// DELETE /tasks/:id
func deleteTask(c *girl.Context) girl.View {
model.DeleteTask(c.GetNumParam("id"))
return c.RenderText("success")
}
示例4: updateTask
// 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)
}
示例5: getTask
// 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)
}
示例6: getTasks
// GET /tasks
func getTasks(c *girl.Context) girl.View {
tasks := model.FindTasks()
return c.RenderJSON(tasks)
}
示例7: index
// GET /
func index(c *girl.Context) girl.View {
return c.Render("index", model.User{Name: model.GetUser()})
}
示例8: Index
func Index(c *girl.Context) girl.View {
return c.RenderText("hello world")
}