add get labels endpoint
This commit is contained in:
parent
938599d526
commit
93bb34ad76
16
giteaClient/createIssueProxy.go
Normal file
16
giteaClient/createIssueProxy.go
Normal file
@ -0,0 +1,16 @@
|
||||
package giteaClient
|
||||
|
||||
type GetCreateIssueProxy struct {
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Assignee string `json:"assignee"`
|
||||
Labels []int64 `json:"labels"`
|
||||
Closed bool `json:"closed"`
|
||||
}
|
||||
|
||||
type PostCreateIssueProxy struct {
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Labels []int64 `json:"labels"`
|
||||
}
|
||||
|
@ -58,12 +58,21 @@ func GetIssue(issueID int64) (*gitea.Issue, error) {
|
||||
func GetIssueComments(issueID int64) ([]*gitea.Comment, error) {
|
||||
giteaIssueComments, err := giteaClient.ListIssueComments(giteaOwner, giteaRepo, issueID)
|
||||
if( err != nil){
|
||||
fmt.Println(fmt.Sprintf("Gitea error: %+v", err.Error()))
|
||||
fmt.Println(fmt.Sprintf("Gitea get isse comments error: %+v", err.Error()))
|
||||
return nil, err
|
||||
}
|
||||
return giteaIssueComments, nil
|
||||
}
|
||||
|
||||
func GetLabels() ([]*gitea.Label, error) {
|
||||
giteaLabels, err := giteaClient.ListRepoLabels(giteaOwner, giteaRepo)
|
||||
if( err != nil){
|
||||
fmt.Println(fmt.Sprintf("Gitea get labels error: %+v", err.Error()))
|
||||
return nil, err
|
||||
}
|
||||
return giteaLabels, nil
|
||||
}
|
||||
|
||||
func CreateIssue(issue gitea.Issue){
|
||||
|
||||
}
|
23
main.go
23
main.go
@ -30,10 +30,10 @@ func init() {
|
||||
panic("failed to connect database")
|
||||
}
|
||||
if err := env.Parse(&giteaConfig); err != nil {
|
||||
panic("ENV error")
|
||||
panic(fmt.Sprintf("ENV error: %+v", err.Error()))
|
||||
}
|
||||
if err := env.Parse(&proxyConfig); err != nil {
|
||||
panic("ENV error")
|
||||
panic(fmt.Sprintf("ENV error: %+v", err.Error()))
|
||||
}
|
||||
|
||||
giteaClient.SetUp(giteaConfig)
|
||||
@ -49,10 +49,14 @@ func main() {
|
||||
|
||||
v1 := router.Group("/api/v1/issues")
|
||||
{
|
||||
v1.GET("/", getIssues)
|
||||
v1.GET("/:id", getIssue) //Migrate the schema
|
||||
v1.GET("", getIssues)
|
||||
v1.GET("/:id", getIssue)
|
||||
v1.GET("/:id/comments", getIssueComments)
|
||||
}
|
||||
|
||||
v1.GET("/:id/comments", getIssue)
|
||||
labels := router.Group("/api/v1/labels")
|
||||
{
|
||||
labels.GET("", getLabels)
|
||||
}
|
||||
|
||||
_ = router.Run()
|
||||
@ -101,3 +105,12 @@ func getIssueComments(c *gin.Context) {
|
||||
}
|
||||
c.AsciiJSON(http.StatusOK, issueComments)
|
||||
}
|
||||
|
||||
func getLabels(c *gin.Context) {
|
||||
labels, err := giteaClient.GetLabels()
|
||||
if err != nil {
|
||||
c.AbortWithStatus(http.StatusNotFound)
|
||||
}
|
||||
c.AsciiJSON(http.StatusOK, labels)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user