Example #1
0
func (this *RestServer) handlePeer(c *gin.Context) {
	address := c.MustGet("address").(string)
	peer, err := this.pipe.Net().Peer(address)
	if err != nil {
		c.AbortWithError(500, err)
	}
	c.Writer.WriteHeader(200)
	this.codec.Encode(peer, c.Writer)
}
Example #2
0
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)
}
Example #3
0
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)
}
Example #4
0
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)
}
Example #5
0
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)
}
Example #6
0
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)
}