-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34149ea
commit e41afc7
Showing
3 changed files
with
49 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package status | ||
|
||
import ( | ||
"net/http" | ||
"runtime" | ||
"soarca/models/api" | ||
"soarca/utils" | ||
"time" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
var status = api.Status{Uptime: api.Uptime{Since: time.Now(), Milliseconds: 0}, | ||
Mode: utils.GetEnv("LOG_MODE", "production"), | ||
Runtime: runtime.GOOS} | ||
|
||
func SetVersion(version string) { | ||
status.Version = version | ||
} | ||
|
||
// /Status GET handler for handling status api calls | ||
// Returns the status model object for SOARCA | ||
// | ||
// @Summary gets the SOARCA status | ||
// @Schemes | ||
// @Description return SOARCA status | ||
// @Tags status | ||
// @Produce json | ||
// @success 200 {object} api.Status | ||
// @failure 400 {object} api.Error | ||
// @Router /status [GET] | ||
func Api(g *gin.Context) { | ||
|
||
status.Uptime.Milliseconds = uint64(time.Since(status.Uptime.Since).Milliseconds()) | ||
status.Time = time.Now() | ||
|
||
g.JSON(http.StatusOK, status) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,22 @@ | ||
package coa | ||
package status | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
func Helloworld(g *gin.Context) { | ||
g.JSON(http.StatusOK, "helloworld from /status") | ||
} | ||
|
||
func id_tester(g *gin.Context) { | ||
// Get the value of the 'id' parameter from the URL | ||
id := g.Param("id") | ||
fmt.Println(id) | ||
func Pong(g *gin.Context) { | ||
g.Data(http.StatusOK, "text/plain", []byte("pong")) | ||
} | ||
|
||
// GET /status | ||
// GET /status/playbook | ||
// GET /status/playbook/id | ||
// GET /status/coa/id | ||
// GET /status/history | ||
// GET /status/ping | ||
func Routes(route *gin.Engine) { | ||
coa := route.Group("/status") | ||
router := route.Group("/status") | ||
{ | ||
coa.GET("/", Helloworld) | ||
coa.GET("/playbook/:id", id_tester) | ||
coa.GET("/coa/:id", id_tester) | ||
coa.GET("/history", Helloworld) | ||
// workflow.POST() | ||
router.GET("/", Api) | ||
router.GET("/ping", Pong) | ||
|
||
} | ||
} |