-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
37 lines (34 loc) · 943 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
package main
import (
"jea-api/api"
"jea-api/common"
"jea-api/database"
"jea-api/environment"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
)
func main() {
var engine = gin.Default()
var environmentManager = LoadEnvironment()
db, err := database.NewDatabase(database.ConnectionInfo{
Host: environmentManager.DatabaseHost,
Port: environmentManager.DatabasePort,
User: environmentManager.DatabaseUser,
Database: environmentManager.DatabaseDatabase,
Password: environmentManager.DatabasePassword,
URL: environmentManager.DatabaseURL,
Driver: "postgres",
}, true)
if err != nil {
logrus.WithField("error", err.Error()).Panic("Error in connect with database")
return
}
engine.Use(common.CORS())
engine.Use(database.UseDatabase(db))
environment.SetupDatabase(db)
api.NewAPI(engine)
err = engine.Run()
if err != nil {
logrus.Error("Error in start Server. Error: ", err.Error())
}
}