v1.0.0: health: add a simple healthcheck
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
82a3ced276
commit
c78316301f
2 changed files with 32 additions and 1 deletions
19
cmd/main.go
19
cmd/main.go
|
|
@ -23,6 +23,10 @@ func isLoggedIn(c echo.Context) error {
|
|||
return c.NoContent(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func health(c echo.Context) error {
|
||||
return c.NoContent(http.StatusOK)
|
||||
}
|
||||
|
||||
func init_database() {
|
||||
var err error
|
||||
|
||||
|
|
@ -38,6 +42,16 @@ func skip_auth(c echo.Context) bool {
|
|||
if c.Request().Method == "POST" && c.Path() == "/" {
|
||||
return true
|
||||
}
|
||||
if c.Request().Method == "GET" && c.Path() == "/health" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func skip_log(c echo.Context) bool {
|
||||
if c.Request().Method == "GET" && c.Path() == "/health" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +64,9 @@ func main() {
|
|||
e := echo.New()
|
||||
|
||||
// Middleware
|
||||
e.Use(middleware.Logger())
|
||||
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
|
||||
Skipper: skip_log,
|
||||
}))
|
||||
e.Use(middleware.Recover())
|
||||
e.Use(middleware.CORS())
|
||||
e.Use(lib.AuthMiddleware(skip_auth))
|
||||
|
|
@ -59,6 +75,7 @@ func main() {
|
|||
e.GET("/", isLoggedIn)
|
||||
e.POST("/", login)
|
||||
e.DELETE("/", logout)
|
||||
e.GET("/health", health)
|
||||
|
||||
// Start server
|
||||
e.Logger.Fatal(e.Start(":1222"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue