-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
36 lines (32 loc) · 818 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
package main
import (
"context"
"github.com/gin-gonic/gin"
"go.mongodb.org/mongo-driver/mongo"
"log"
"userCrudApp/config"
"userCrudApp/controllers"
"userCrudApp/services"
)
var (
server *gin.Engine
userService services.UserService
userController controllers.UserController
ctx context.Context
userCollection *mongo.Collection
mongoClient *mongo.Client
err error
)
func init() {
ctx = context.TODO()
mongoClient = config.ConnectDB()
userCollection = config.GetCollection(mongoClient, "users")
userService = services.NewUserServiceImpl(userCollection, ctx)
userController = controllers.NewUserController(userService)
server = gin.Default()
}
func main() {
router := server.Group("/v1")
userController.RegisterRoutes(router)
log.Fatal(server.Run(":8000"))
}