Skip to content

Commit

Permalink
`Added readBandwidth function and updated ApplyRoutes to use it inste…
Browse files Browse the repository at this point in the history
…ad of readPeerStats for /bandwidth endpoint`
  • Loading branch information
p-shubh committed Feb 22, 2025
1 parent 11006d5 commit 37d31da
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion api/v1/peer/peer_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func ApplyRoutes(r *gin.RouterGroup) {
g := r.Group("/peer")
{
g.GET("/stats", readPeerStats)
g.GET("/bandwidth", readPeerStats)
g.GET("/bandwidth", readBandwidth)
}
}

Expand All @@ -47,6 +47,20 @@ func readPeerStats(c *gin.Context) {
})
}

func readBandwidth(c *gin.Context) {
peerData, err := getBandwidthStats()
if err != nil {
log.WithFields(util.StandardFields).Error("Failure in reading server")
response := core.MakeErrorResponse(500, err.Error(), nil, nil, nil)
c.JSON(http.StatusInternalServerError, response)
return
}

c.JSON(http.StatusOK, gin.H{
"data": peerData,
})
}

// // Function to get stats for all peers and output them as JSON
// func getPeerStatsJSON() (string, error) {
// // Run the `wg show` command to get peer stats
Expand Down

0 comments on commit 37d31da

Please sign in to comment.