Skip to content

Commit

Permalink
Return stats of network via /stats url
Browse files Browse the repository at this point in the history
  • Loading branch information
gen1us2k committed Jan 24, 2016
1 parent 2cfd197 commit 97bb5b1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions common/httpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package common

import (
"encoding/json"
"fmt"
"log"
"net/http"
_ "net/http/pprof"
Expand All @@ -18,8 +17,9 @@ type HttpService struct {
}

type Response struct {
IfaceName string `json:"iface"`
LocalIPAddr string `json:"local_ip_addr"`
IfaceName string `json:"iface"`
LocalIPAddr string `json:"local_ip_addr"`
Peers interface{} `json:"net_peers"`
}

func (hs *HttpService) Name() string {
Expand All @@ -37,10 +37,9 @@ func (hs *HttpService) Run() error {
http.HandleFunc("/stats", func(w http.ResponseWriter, r *http.Request) {
iName := hs.iface.instance.Name()
ipAddr := hs.localnode.State().PrivateIP.String()
fmt.Println(iName, ipAddr)
resp := Response{iName, ipAddr}
peers := hs.iface.netTable.PeerAddresses()
resp := Response{iName, ipAddr, peers}
data, err := json.Marshal(resp)
fmt.Println(hs.iface.instance.Name())
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
Expand Down

0 comments on commit 97bb5b1

Please sign in to comment.