本文整理匯總了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")
}