-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (37 loc) · 1.13 KB
/
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
package main
import (
"cakewai/cakewai.com/api/middlewares"
"cakewai/cakewai.com/api/routes"
appconfig "cakewai/cakewai.com/component/appcfg"
appctx "cakewai/cakewai.com/component/appcontext"
mongodb "cakewai/cakewai.com/infras/mongo"
"fmt"
"log"
"os"
"time"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
appcfg, err := appconfig.LoadEnv()
if err != nil {
log.Fatalf("Error happened while loading config %v", err)
}
fmt.Print("Line 22")
client, err := mongodb.ConnectWithMongodb(appcfg)
if err != nil {
log.Fatalf("Error happened while connect to database %v", err)
}
db := client.Database(os.Getenv("DB_NAME"))
ctx := appctx.NewAppContext(db, appcfg.SECRET_KEY)
r.Use(middlewares.CORS())
r.Use(middlewares.Recover(ctx))
routes.SetUp(appcfg, time.Second*3600, db, r)
r.Use(middlewares.TraceMiddleware("root middleware"))
// r.GET("/", func(ctx *gin.Context) {
// ctx.JSON(http.StatusOK, gin.H{"data": "hello everyone, welcome to my chanel"})
// })
r.Run("localhost:8080")
//r.Run()
}
//mongodb+srv://hoaibao123456:9DQ18WlqmeoF9f7u@cakewai.auh9m.mongodb.net/?retryWrites=true&w=majority&appName=cakewai