-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
31 lines (26 loc) · 1.06 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
package main
import (
"github.com/zucchinidev/clean-architecture-golang/infrastructure"
"github.com/zucchinidev/clean-architecture-golang/usescases"
"net/http"
)
func main() {
dbHandler := infrastructure.NewSqliteHandler("./order.db")
availableRepositories := infrastructure.GetAvailableRepositories()
handlers := make(map[string]infrastructure.DBHandler)
handlers[availableRepositories.UserRepo] = dbHandler
handlers[availableRepositories.CustomerRepo] = dbHandler
handlers[availableRepositories.ItemRepo] = dbHandler
handlers[availableRepositories.OrderRepo] = dbHandler
orderInteractor := &usescases.OrderInteractor{
UserRepository: infrastructure.NewDBUserRepo(handlers),
ItemRepository: infrastructure.NewDBItemRepo(handlers),
OrderRepository: infrastructure.NewDBOrderRepo(handlers),
}
webserviceHandler := infrastructure.WebServiceHandler{}
webserviceHandler.OrderInteractor = orderInteractor
http.HandleFunc("/orders", func(res http.ResponseWriter, req *http.Request) {
webserviceHandler.ShowOrder(res, req)
})
http.ListenAndServe(":8080", nil)
}