-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
45 lines (34 loc) · 754 Bytes
/
main.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
40
41
42
43
44
45
package main
import (
"os"
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
func main() {
app := fiber.New(fiber.Config{
DisableStartupMessage: true,
})
SetupLogger()
app.Get("/", func(c *fiber.Ctx) error {
return c.JSON(map[string]string{
"message": "Hello, World 👋!",
})
})
app.Get("/env", func(c *fiber.Ctx) error {
hostName, err := os.Hostname()
if err != nil {
hostName = "error"
}
return c.JSON(map[string]string{
"version": os.Getenv("APP_VERSION"),
"env": os.Getenv("FROM_DEPLOYMENT"),
"hostname": hostName,
})
})
app.Listen(":8080")
}
func SetupLogger() {
zerolog.TimeFieldFormat = zerolog.TimeFormatUnixMicro
log.Warn().Msg("Logger Started")
}