本文整理汇总了Golang中github.com/coocood/jas.Context.RequireInt方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.RequireInt方法的具体用法?Golang Context.RequireInt怎么用?Golang Context.RequireInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coocood/jas.Context
的用法示例。
在下文中一共展示了Context.RequireInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetVerify
// GetVerify moves a node from the verification queue to the normal
// database, as identified by its long random ID.
func (*Api) GetVerify(ctx *jas.Context) {
id := ctx.RequireInt("id")
ip, verifyerr, err := Db.VerifyQueuedNode(id, ctx.Request)
if verifyerr != nil {
// If there was an error inverification, there was no internal
// error, but the circumstances of the verification were
// incorrect. It has not been removed from the database.
ctx.Error = jas.NewRequestError(verifyerr.Error())
return
} else if err == sql.ErrNoRows {
// If we encounter a ErrNoRows, then there was no node with
// that ID. Report it.
ctx.Error = jas.NewRequestError("invalid id")
l.Noticef("%q attempted to verify invalid ID\n", ctx.RemoteAddr)
return
} else if err != nil {
// If we encounter any other database error, it is an internal
// error and needs to be logged.
ctx.Error = jas.NewInternalError(err)
l.Err(err)
return
}
// If there was no error, inform the user that it was successful,
// and log it.
ctx.Data = "successful"
l.Infof("Node %q verified", ip)
}
示例2: Get
func (*Sporocila) Get(ctx *jas.Context) { // `GET /sporocila/:offset`
offset := ctx.RequireInt("offset")
err, res := sporocilo.NajdiSporocila(int(offset))
if err == nil {
ctx.Data = res
}
}