Skip to content

Commit

Permalink
fix(backend): invalid error format
Browse files Browse the repository at this point in the history
- fix invalid error format in `teams/:id/apps` api response
- improve function names
  • Loading branch information
detj committed Nov 18, 2023
1 parent 55d9f63 commit a8b63e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion measure-backend/measure-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func main() {
r.Use(cors).GET("/apps/:id/metrics", authorize(), getAppMetrics)
r.Use(cors).GET("/apps/:id/filters", authorize(), getAppFilters)
r.Use(cors).GET("/teams", authorize(), getTeams)
r.Use(cors).GET("/teams/:id/apps", authorize(), getApps)
r.Use(cors).GET("/teams/:id/apps", authorize(), getTeamApps)

r.Run(":8080") // listen and serve on 0.0.0.0:8080
}
5 changes: 3 additions & 2 deletions measure-backend/measure-go/teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func getTeams(c *gin.Context) {
c.Data(http.StatusOK, "application/json", []byte(teams))
}

func getApps(c *gin.Context) {
func getTeamApps(c *gin.Context) {
appMap := map[string]string{
"6c0f7001-1e81-4cb0-a08c-2a29e94e36da": `[
{
Expand Down Expand Up @@ -78,7 +78,8 @@ func getApps(c *gin.Context) {
if err != nil {
msg := `team id is invalid or missing`
fmt.Println(msg, err)
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
c.JSON(http.StatusBadRequest, gin.H{"error": msg, "details": err.Error()})
return
}

app := appMap[teamId.String()]
Expand Down

0 comments on commit a8b63e8

Please sign in to comment.