This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
atsebay.t/gradation.go

33 lines
1002 B
Go

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)
})
}