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