Skip to content
Permalink
Browse files

Improving API and adding a way to tell a service is home made

  • Loading branch information...
Depado committed Mar 29, 2016
1 parent 5939b0f commit 0b289f51e3c3c4526fa1e62e569694c71d7453a6
Showing with 19 additions and 0 deletions.
  1. +2 −0 configuration/configuration.go
  2. +16 −0 main.go
  3. +1 −0 models/service.go
@@ -28,6 +28,7 @@ type service struct {
Repo string `yaml:"repo"`
URL string `yaml:"url"`
Icon string `yaml:"icon"`
Own bool `yaml:"own"`
}

type unparsed struct {
@@ -98,6 +99,7 @@ func (c Configuration) Parse() (models.Services, error) {
BuildURL: buildURL,
RepoURL: repoURL,
Icon: "/static/custom/" + s.Icon,
Own: s.Own,
}
}
return services, nil
16 main.go
@@ -28,6 +28,20 @@ func status(c *gin.Context) {
c.JSON(200, resp)
}

func dump(c *gin.Context) {
c.JSON(200, all)
}

func own(c *gin.Context) {
resp := models.Services{}
for _, s := range all {
if s.Own {
resp = append(resp, s)
}
}
c.JSON(http.StatusOK, resp)
}

func main() {
var err error
if err = configuration.Load("conf.yml"); err != nil {
@@ -49,6 +63,8 @@ func main() {
api := r.Group("/api")
{
api.GET("/status", status)
api.GET("/dump/all", dump)
api.GET("/dump/own", own)
}

r.GET("/login", auth.Login)
@@ -26,6 +26,7 @@ type Service struct {
Icon string `json:"icon"`
LastBuilds Builds `json:"last_builds"`
LastCommits Commits `json:"last_commits"`
Own bool `json:"own"`
}

// CheckStatus checks if the service is running

0 comments on commit 0b289f5

Please sign in to comment.
You can’t perform that action at this time.