当前位置: 首页>>代码示例>>Golang>>正文


Golang Context.RequireInt方法代码示例

本文整理汇总了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)
}
开发者ID:nycmeshnet,项目名称:nodeatlas,代码行数:29,代码来源:api.go

示例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
	}
}
开发者ID:ubuntu-si,项目名称:go-ubuntusi-log,代码行数:7,代码来源:rest.go


注:本文中的github.com/coocood/jas.Context.RequireInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。