gitlin/pages/repo.go

50 行
1.2 KiB
Go
Raw 通常表示 履歴

package pages
import (
"codeberg.org/Odyssium/gothub/utils"
"github.com/gofiber/fiber/v2"
)
type Repo struct {
Fullname string
Description string
HtmlUrl string
Fork bool
Parent string
Stars int64
Forks int64
Watchers int64
Language string
License string
DefaultBranch string
}
type RepoFiles struct {
Name string
Path string
Type string
}
func HandleRepo(c *fiber.Ctx) error {
var repoArray []Repo
// get repo
repo := utils.GetRequest("https://api.github.com/repos/" + c.Params("user") + "/" + c.Params("repo"))
repoArray = append(repoArray, Repo{
Fullname: repo.Get("full_name").String(),
Description: repo.Get("description").String(),
HtmlUrl: repo.Get("html_url").String(),
Fork: repo.Get("fork").Bool(),
Stars: repo.Get("stargazers_count").Int(),
Forks: repo.Get("forks_count").Int(),
Watchers: repo.Get("watchers_count").Int(),
Language: repo.Get("language").String(),
License: repo.Get("license").Get("name").String(),
Parent: repo.Get("parent").Get("full_name").String(),
DefaultBranch: repo.Get("default_branch").String(),
})
return c.Render("repo", fiber.Map{
"repo": repoArray,
})
}