Skip to content

Commit

Permalink
Improving API and adding a way to tell a service is home made
Browse files Browse the repository at this point in the history
  • Loading branch information
depado committed Mar 29, 2016
1 parent 5939b0f commit 0b289f5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions models/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0b289f5

Please sign in to comment.