package main import ( "log" "net/http" "github.com/drone/drone-go/drone" "github.com/gin-gonic/gin" ) func declareAPIAdminGradationRoutes(router *gin.RouterGroup) { router.GET("/gradation_repositories", func(c *gin.Context) { client := drone.NewClient(droneEndpoint, droneConfig) result, err := client.RepoList() if err != nil { log.Println("Unable to retrieve the repository list:", err.Error()) c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to retrieve the repository list."}) return } c.JSON(http.StatusOK, result) }) router.POST("/gradation_repositories/sync", func(c *gin.Context) { client := drone.NewClient(droneEndpoint, droneConfig) result, err := client.RepoListSync() if err != nil { log.Println("Unable to retrieve the repository list:", err.Error()) c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to retrieve the repository list."}) return } c.JSON(http.StatusOK, result) }) }