本文整理汇总了Golang中github.com/labstack/echo.Context.RemoveId方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.RemoveId方法的具体用法?Golang Context.RemoveId怎么用?Golang Context.RemoveId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/labstack/echo.Context
的用法示例。
在下文中一共展示了Context.RemoveId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CloseSession
// CloseSession takes a digits auth and converts it into internal auth
func CloseSession(c *echo.Context) (int, interface{}) {
hauth, ok := c.Get("habloAuth").(*models.HabloAuth)
if !ok {
return msg.Forbidden("must include an authorization")
}
log.Printf("Awaiting for [HabloAuth = %s] deletion", hauth.ID.Hex())
err := mangos.Execute(collection, func(c *mgo.Collection) error {
return c.RemoveId(hauth.ID)
})
if err != nil {
log.Printf("Cannot remove [HabloAuth = %s]: %s", hauth.ID.Hex(), err)
return msg.InternalError(err)
}
log.Printf("Removed [HabloAuth = %s]", hauth.ID.Hex())
return msg.Ok("see you")
}
示例2: Delete
// Delete removes the indicated object from database.
// ID must be the same as session.
func Delete(c *echo.Context) (int, interface{}) {
var err error
reqid, _ := strconv.ParseInt(c.Param("id"), 10, 64)
attid, _ := c.Get("digitsID").(int64)
if reqid == attid {
// Execute delete
log.Printf("Awaiting for [Profile = %d] delete", reqid)
err = mangos.Execute(collection, func(c *mgo.Collection) error {
return c.RemoveId(reqid)
})
if err != nil {
log.Printf("Cannot delete [Profile = %d]: %s", reqid, err)
return msg.InternalError(err)
}
log.Printf("Deleted [Profile = %d]", reqid)
return msg.Ok("deleted")
}
return msg.Forbidden("the id does not belongs to user")
}