-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (35 loc) · 899 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 (
"github.com/gin-gonic/gin"
"github.com/saffrondigits/api/controller"
"github.com/saffrondigits/api/db"
"github.com/saffrondigits/api/repo"
"github.com/sirupsen/logrus"
)
const (
Address = "127.0.0.1:5000"
)
func init() {
gin.SetMode(gin.ReleaseMode)
}
func main() {
log := logrus.New()
log.SetFormatter(&logrus.TextFormatter{
DisableColors: false,
FullTimestamp: true,
})
log.Infof("Establishing db connection...")
dbInst, err := db.ConnectTOTheDatabase()
if err != nil {
log.Errorf("Error establishing db connection: %v", err)
return
}
log.Infof("Successfully connected to the db!")
_ = dbInst
sqlImpl := repo.NewSqlDbImplementation(dbInst)
apiCtrl := controller.NewApiController(sqlImpl, log)
r := gin.Default()
router := controller.SetUpRoute(r, apiCtrl)
log.Infof("Starting the server at address %s", Address)
router.Run(Address)
}