-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
47 lines (37 loc) · 1.35 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
45
46
47
package main
import (
"net/http"
"github.com/gorilla/mux"
"main.go/database"
_ProductUsecase "main.go/product/usecase"
_ShoppingCartUsecase "main.go/shopping_cart/usecase"
"main.go/transaction"
_UserUsecase "main.go/user/usecase"
_ProductHandler "main.go/product/deliver/http"
_ShoppingCartHandler "main.go/shopping_cart/deliver/http"
_UserHandler "main.go/user/deliver/http"
_ProductRepo "main.go/product/repository"
_ShoppingCartRepo "main.go/shopping_cart/repository"
_UserRepo "main.go/user/repository"
)
func main() {
db, err := database.Connect()
if err != nil {
println(err)
return
}
router := mux.NewRouter()
userRepo := _UserRepo.NewUserRepo(db)
productRepo := _ProductRepo.NewProductsRepo(db)
shoppingCartRepo := _ShoppingCartRepo.NewShoppingCartRepo(db)
uw := transaction.NewUW(db)
productUsecase := _ProductUsecase.NewProductUsecase(*productRepo)
shoppingCartUsecase := _ShoppingCartUsecase.NewShoppingCartUsecase(*shoppingCartRepo)
userUsecase := _UserUsecase.NewUserUsecase(*userRepo, *productUsecase, *productRepo, uw, *shoppingCartUsecase)
_ProductHandler.NewProductHandler(*productUsecase, router)
_ShoppingCartHandler.NewShoppingCartHandler(*shoppingCartUsecase, router)
_UserHandler.NewUserHandler(*userUsecase, router, db)
println("server running")
println("--------------------")
http.ListenAndServe(":8080", router)
}