本文整理匯總了Golang中github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin.Context類的典型用法代碼示例。如果您正苦於以下問題:Golang Context類的具體用法?Golang Context怎麽用?Golang Context使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Context類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: roomGET
func roomGET(c *gin.Context) {
roomid := c.Param("roomid")
userid := fmt.Sprint(rand.Int31())
c.HTML(200, "chat_room", gin.H{
"roomid": roomid,
"userid": userid,
})
}
示例2: 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)
}
示例3: 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)
}
示例4: 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)
}
示例5: 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)
}
示例6: 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)
}
示例7: 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)
}
示例8: 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)
}
示例9: 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)
}
示例10: 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)
}
示例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: 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)
}
示例13: handleEventPoll
func (this *RestServer) handleEventPoll(c *gin.Context) {
subId := c.MustGet("id").(string)
data, err := this.eventSubs.poll(subId)
if err != nil {
c.AbortWithError(500, err)
}
c.Writer.WriteHeader(200)
this.codec.Encode(&ep.PollResponse{data}, c.Writer)
}
示例14: handleBlock
func (this *RestServer) handleBlock(c *gin.Context) {
height := c.MustGet("height").(int)
block, err := this.pipe.Blockchain().Block(height)
if err != nil {
c.AbortWithError(500, err)
}
c.Writer.WriteHeader(200)
this.codec.Encode(block, c.Writer)
}
示例15: handleUnconfirmedTxs
func (this *RestServer) handleUnconfirmedTxs(c *gin.Context) {
txs, err := this.pipe.Transactor().UnconfirmedTxs()
if err != nil {
c.AbortWithError(500, err)
}
c.Writer.WriteHeader(200)
this.codec.Encode(txs, c.Writer)
}