/
app.go
39 lines (31 loc) · 1.11 KB
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"fmt"
"github.com/gofiber/fiber/v2"
"github.com/projectkeas/sdks-service/configuration"
"github.com/projectkeas/sdks-service/healthchecks/http"
log "github.com/projectkeas/sdks-service/logger"
"github.com/projectkeas/sdks-service/server"
)
func main() {
app := server.New("testing")
app.WithRequiredConfigMap("config-1").WithInMemoryConfiguration("default", map[string]string{
"test": "value",
}).WithEnvironmentVariableConfiguration("DOTNET_")
app.WithLivenessHealthCheck(http.NewHttpHealthCheck("https://google.com"))
app.WithReadinessHealthCheck(http.NewHttpHealthCheck("https://bing.com"))
app.ConfigureHandlers(func(f *fiber.App, server *server.Server) {
f.Get("/", func(c *fiber.Ctx) error {
value := server.GetConfiguration().GetStringValueOrDefault("log.level", "not set")
return c.SendString(fmt.Sprintf("Hello, World 👋! Log Level is: %s", value))
})
})
host := app.Build()
config := host.GetConfiguration()
config.RegisterChangeNotificationHandler(func(config configuration.ConfigurationRoot) {
if log.Logger != nil {
log.Logger.Info("YAY!")
}
})
host.Run()
}