added health check endpoint + fixed logging

* set go-gin to release mode
* added health check endpoint
* excluded endpoint from logger

see #63
This commit is contained in:
Bernhard B
2021-01-16 20:12:12 +01:00
parent 0ae4a5b0af
commit f5d3880c49
6 changed files with 78 additions and 4 deletions

View File

@@ -45,7 +45,13 @@ func main() {
avatarTmpDir := flag.String("avatar-tmp-dir", "/tmp/", "Avatar tmp directory")
flag.Parse()
router := gin.Default()
router := gin.New()
router.Use(gin.LoggerWithConfig(gin.LoggerConfig{
SkipPaths: []string{"/v1/health"}, //do not log the health requests (to avoid spamming the log file)
}))
router.Use(gin.Recovery())
log.Info("Started Signal Messenger REST API")
api := api.NewApi(*signalCliConfig, *attachmentTmpDir, *avatarTmpDir)
@@ -56,6 +62,11 @@ func main() {
about.GET("", api.About)
}
health := v1.Group("/health")
{
health.GET("", api.Health)
}
register := v1.Group("/register")
{
register.POST(":number", api.RegisterNumber)