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


Golang Context.AbortWithError方法代码示例

本文整理汇总了Golang中github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin.Context.AbortWithError方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.AbortWithError方法的具体用法?Golang Context.AbortWithError怎么用?Golang Context.AbortWithError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin.Context的用法示例。


在下文中一共展示了Context.AbortWithError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: contentTypeMW

// Just a catch-all for POST requests right now. Only allow default charset (utf8).
func contentTypeMW(c *gin.Context) {
	if c.Request.Method == "POST" && c.ContentType() != "application/json" {
		c.AbortWithError(415, fmt.Errorf("Media type not supported: "+c.ContentType()))
	} else {
		c.Next()
	}
}
开发者ID:ZhuZhengyi,项目名称:eris-db,代码行数:8,代码来源:server.go

示例2: handleChainId

func (this *RestServer) handleChainId(c *gin.Context) {
	cId, err := this.pipe.Blockchain().ChainId()
	if err != nil {
		c.AbortWithError(500, err)
	}
	c.Writer.WriteHeader(200)
	this.codec.Encode(&ep.ChainId{cId}, c.Writer)
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:8,代码来源:restServer.go

示例3: handleGenesisHash

func (this *RestServer) handleGenesisHash(c *gin.Context) {
	gh, err := this.pipe.Blockchain().GenesisHash()
	if err != nil {
		c.AbortWithError(500, err)
	}
	c.Writer.WriteHeader(200)
	this.codec.Encode(&ep.GenesisHash{gh}, c.Writer)
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:8,代码来源:restServer.go

示例4: handleBlockchainInfo

func (this *RestServer) handleBlockchainInfo(c *gin.Context) {
	bci, err := this.pipe.Blockchain().Info()
	if err != nil {
		c.AbortWithError(500, err)
	}
	c.Writer.WriteHeader(200)
	this.codec.Encode(bci, c.Writer)
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:8,代码来源:restServer.go

示例5: handleLatestBlock

func (this *RestServer) handleLatestBlock(c *gin.Context) {
	lb, err := this.pipe.Blockchain().LatestBlock()
	if err != nil {
		c.AbortWithError(500, err)
	}
	c.Writer.WriteHeader(200)
	this.codec.Encode(lb, c.Writer)
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:8,代码来源:restServer.go

示例6: subIdParam

func subIdParam(c *gin.Context) {
	subId := c.Param("id")
	if len(subId) != 64 || !util.IsHex(subId) {
		c.AbortWithError(400, fmt.Errorf("Malformed event id"))
	}
	c.Set("id", subId)
	c.Next()
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:8,代码来源:restServer.go

示例7: handleListeners

func (this *RestServer) handleListeners(c *gin.Context) {
	listeners, err := this.pipe.Net().Listeners()
	if err != nil {
		c.AbortWithError(500, err)
	}
	c.Writer.WriteHeader(200)
	this.codec.Encode(&ep.Listeners{listeners}, c.Writer)
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:8,代码来源:restServer.go

示例8: handleNetworkInfo

func (this *RestServer) handleNetworkInfo(c *gin.Context) {
	nInfo, err := this.pipe.Net().Info()
	if err != nil {
		c.AbortWithError(500, err)
	}
	c.Writer.WriteHeader(200)
	this.codec.Encode(nInfo, c.Writer)
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:8,代码来源:restServer.go

示例9: handleMoniker

func (this *RestServer) handleMoniker(c *gin.Context) {
	moniker, err := this.pipe.Net().Moniker()
	if err != nil {
		c.AbortWithError(500, err)
	}
	c.Writer.WriteHeader(200)
	this.codec.Encode(&ep.Moniker{moniker}, c.Writer)
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:8,代码来源:restServer.go

示例10: handleValidatorList

func (this *RestServer) handleValidatorList(c *gin.Context) {
	vl, err := this.pipe.Consensus().Validators()
	if err != nil {
		c.AbortWithError(500, err)
	}
	c.Writer.WriteHeader(200)
	this.codec.Encode(vl, c.Writer)
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:8,代码来源:restServer.go

示例11: handleClientVersion

func (this *RestServer) handleClientVersion(c *gin.Context) {
	version, err := this.pipe.Net().ClientVersion()
	if err != nil {
		c.AbortWithError(500, err)
	}
	c.Writer.WriteHeader(200)
	this.codec.Encode(&ep.ClientVersion{version}, c.Writer)
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:8,代码来源:restServer.go

示例12: handlePeers

func (this *RestServer) handlePeers(c *gin.Context) {
	peers, err := this.pipe.Net().Peers()
	if err != nil {
		c.AbortWithError(500, err)
	}
	c.Writer.WriteHeader(200)
	this.codec.Encode(peers, c.Writer)
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:8,代码来源:restServer.go

示例13: handleStorage

func (this *RestServer) handleStorage(c *gin.Context) {
	addr := c.MustGet("addrBts").([]byte)
	s, err := this.pipe.Accounts().Storage(addr)
	if err != nil {
		c.AbortWithError(500, err)
	}
	c.Writer.WriteHeader(200)
	this.codec.Encode(s, c.Writer)
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:9,代码来源:restServer.go

示例14: handleNameRegEntry

func (this *RestServer) handleNameRegEntry(c *gin.Context) {
	name := c.MustGet("name").(string)
	entry, err := this.pipe.NameReg().Entry(name)
	if err != nil {
		c.AbortWithError(500, err)
	}
	c.Writer.WriteHeader(200)
	this.codec.Encode(entry, c.Writer)
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:9,代码来源:restServer.go

示例15: handleEventUnsubscribe

func (this *RestServer) handleEventUnsubscribe(c *gin.Context) {
	subId := c.MustGet("id").(string)
	err := this.eventSubs.remove(subId)
	if err != nil {
		c.AbortWithError(500, err)
	}
	c.Writer.WriteHeader(200)
	this.codec.Encode(&ep.EventUnsub{true}, c.Writer)
}
开发者ID:alexandrev,项目名称:eris-db,代码行数:9,代码来源:restServer.go


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