From 3ab0366d0ef37836d1dcffec92a4284d18889f31 Mon Sep 17 00:00:00 2001 From: Prince Date: Sun, 17 Sep 2023 12:41:28 +0530 Subject: [PATCH] chore: route changed from scores to vp --- main_test.go | 2 +- routes/handlers.go | 4 ++-- routes/scores.go | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/main_test.go b/main_test.go index 6662f9f..5c5855a 100644 --- a/main_test.go +++ b/main_test.go @@ -73,7 +73,7 @@ func TestScores(t *testing.T) { } // Create an HTTP POST request with the JSON payload - req, err := http.NewRequest("POST", ts.URL+"/scores", bytes.NewBuffer(inputJSON)) + req, err := http.NewRequest("POST", ts.URL+"/vp", bytes.NewBuffer(inputJSON)) if err != nil { t.Fatal(err) } diff --git a/routes/handlers.go b/routes/handlers.go index 90a429b..fea430d 100644 --- a/routes/handlers.go +++ b/routes/handlers.go @@ -29,8 +29,8 @@ func SetupRoutes(clients *utils.Clients) *gin.Engine { r.GET("/strategies/:strategy_id", func(c *gin.Context) { GetStrategy(c) }) - r.POST("/scores", func(c *gin.Context) { - GetScores(c, clients) + r.POST("/vp", func(c *gin.Context) { + GetVotingPower(c, clients) }) return r } diff --git a/routes/scores.go b/routes/scores.go index 01fd0a3..eb7a681 100644 --- a/routes/scores.go +++ b/routes/scores.go @@ -10,14 +10,14 @@ import ( "github.com/gin-gonic/gin" ) -type ScoresBody struct { +type VotingPowerBody struct { Address string `json:"address"` Strategies []strategies.Strategy `json:"strategies"` } -func GetScores(c *gin.Context, clients *utils.Clients) { +func GetVotingPower(c *gin.Context, clients *utils.Clients) { // Create a slice of strategies.Strategy to store the JSON data - var body ScoresBody + var body VotingPowerBody // Bind the JSON data from the request body to the struct if err := c.ShouldBindJSON(&body); err != nil { @@ -25,10 +25,10 @@ func GetScores(c *gin.Context, clients *utils.Clients) { return } - scores := []*big.Float{} + votingPower := []*big.Float{} for _, strategy := range body.Strategies { - scores = append(scores, strategy.Score(clients, body.Address)) + votingPower = append(votingPower, strategy.Score(clients, body.Address)) } - c.JSON(http.StatusOK, scores) + c.JSON(http.StatusOK, votingPower) }