godash/cmd/godash/godash.go

31 lines
730 B
Go
Raw Normal View History

2023-06-16 13:19:10 +02:00
package main
import (
2023-06-21 17:19:21 +02:00
"fmt"
2023-06-16 13:19:10 +02:00
"log"
2023-06-21 17:19:21 +02:00
"net/http"
2023-06-16 13:19:10 +02:00
2023-06-21 17:19:21 +02:00
"gitlab.unjx.de/flohoss/godash/internal/controller"
2023-06-16 13:19:10 +02:00
"gitlab.unjx.de/flohoss/godash/internal/env"
"gitlab.unjx.de/flohoss/godash/internal/logging"
2023-06-21 17:19:21 +02:00
"gitlab.unjx.de/flohoss/godash/internal/router"
2023-06-16 13:19:10 +02:00
"go.uber.org/zap"
)
func main() {
env, err := env.Parse()
if err != nil {
log.Fatal(err)
}
zap.ReplaceGlobals(logging.CreateLogger(env.LogLevel))
2023-06-21 17:19:21 +02:00
r := router.InitRouter()
c := controller.NewController(env)
router.SetupRoutes(r, c)
zap.L().Info("starting server", zap.String("url", fmt.Sprintf("http://localhost:%d", env.Port)))
if err := r.Start(fmt.Sprintf(":%d", env.Port)); err != http.ErrServerClosed {
zap.L().Fatal("cannot start server", zap.Error(err))
}
2023-06-16 13:19:10 +02:00
}