-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (42 loc) · 879 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
47
48
49
package main
import (
"CARIAD/config"
"CARIAD/internal/cache"
"CARIAD/pkg/controllers"
"CARIAD/pkg/service"
"CARIAD/routes"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
"os"
)
var (
serv service.NumberService
controller controllers.NumberController
)
func init() {
config.InitFromFile(".env")
}
// @title CARIAD
// @version 1.0
// @description Take home test exercise.
// @host localhost:8080
// @schemes http
func main() {
log.Info("Hi, this is CARIAD take home test")
createServer()
}
func createServer() {
server := gin.Default()
initializeLayers()
routes.RegisterHandlers(server, controller).RegisterHandlers()
err := server.Run()
if err != nil {
gin.Logger()
log.Error(err)
os.Exit(1)
}
}
func initializeLayers() {
serv = service.NewNumberService(cache.NewCacheService())
controller = controllers.NewController(serv)
}