Skip to content
Permalink
Browse files

Adding basic status API

  • Loading branch information...
Depado committed Mar 29, 2016
1 parent 94500ee commit 5939b0f1161ca96d1e73a8fbb1b5cfa504a3ea40
Showing with 26 additions and 14 deletions.
  1. +12 −0 main.go
  2. +14 −14 models/service.go
12 main.go
@@ -20,6 +20,14 @@ func index(c *gin.Context) {
})
}

func status(c *gin.Context) {
resp := gin.H{}
for _, s := range all {
resp[s.Name] = s.Status
}
c.JSON(200, resp)
}

func main() {
var err error
if err = configuration.Load("conf.yml"); err != nil {
@@ -38,6 +46,10 @@ func main() {
r.Static("/static", "./assets")

r.GET("/", index)
api := r.Group("/api")
{
api.GET("/status", status)
}

r.GET("/login", auth.Login)
r.POST("/login", auth.PostLogin)
@@ -12,20 +12,20 @@ import (

// Service is a single service
type Service struct {
Name string
URL string
ShortURL string
RepoURL string
Host string
BuildAPI string
BuildURL string
CurrentBuildURL string
Last string
RespTime time.Duration
Status int
Icon string
LastBuilds Builds
LastCommits Commits
Name string `json:"name"`
URL string `json:"url"`
ShortURL string `json:"short_url"`
RepoURL string `json:"repo_url"`
Host string `json:"host"`
BuildAPI string `json:"build_api"`
BuildURL string `json:"build_url"`
CurrentBuildURL string `json:"current_build_url"`
Last string `json:"last"`
RespTime time.Duration `json:"resp_time"`
Status int `json:"status"`
Icon string `json:"icon"`
LastBuilds Builds `json:"last_builds"`
LastCommits Commits `json:"last_commits"`
}

// CheckStatus checks if the service is running

0 comments on commit 5939b0f

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