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) }
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) }
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) }
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) }
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) }
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) }