mvp
This commit is contained in:
parent
5d40de4bf3
commit
902cb5dd23
5 changed files with 67 additions and 3 deletions
37
http.go
Normal file
37
http.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package hoboken
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Listen(host string, p *Projects) {
|
||||
r := gin.Default()
|
||||
r.GET("/", func(c *gin.Context) {
|
||||
for _, x := range p.projects {
|
||||
c.String(http.StatusOK, "%s\n", x.Name)
|
||||
}
|
||||
})
|
||||
r.GET("/hook", func(c *gin.Context) {
|
||||
project := c.Query("project")
|
||||
if project == "" {
|
||||
c.AbortWithStatus(http.StatusBadRequest)
|
||||
}
|
||||
p.RLock()
|
||||
defer p.RUnlock()
|
||||
for _, x := range p.projects {
|
||||
if x.Name == project {
|
||||
err := x.Exec()
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, "Err, didn't run")
|
||||
return
|
||||
}
|
||||
c.String(http.StatusOK, "Successfully ran")
|
||||
return
|
||||
}
|
||||
}
|
||||
c.String(http.StatusBadRequest, "No such project")
|
||||
})
|
||||
r.Run(host)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue