-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (32 loc) · 884 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
46
package main
import (
"log"
"strings"
"github.com/gofiber/fiber/v3"
"github.com/onimarufl/neversitup-test-template/handler"
"github.com/onimarufl/neversitup-test-template/repository"
"github.com/onimarufl/neversitup-test-template/service"
"github.com/spf13/viper"
)
func init() {
initViper()
}
func main() {
service := service.NewService(repository.NewRepository())
handler := handler.NewHandler(service)
app := fiber.New()
app.Get("/alive", func(c fiber.Ctx) error {
return c.JSON("alive")
})
app.Get("/getUserById", handler.HandlerGetUser)
app.Listen(":" + viper.GetString("app.port"))
}
func initViper() {
viper.AddConfigPath("configs")
viper.SetConfigName("config")
if err := viper.ReadInConfig(); err != nil {
log.Fatalf("cannot read in viper config:%s", err)
}
viper.AutomaticEnv()
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
}