-
Notifications
You must be signed in to change notification settings - Fork 106
/
main.go
32 lines (26 loc) · 955 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
package main
import (
"usecases"
"interfaces"
"infrastructure"
"net/http"
)
func main() {
dbHandler := infrastructure.NewSqliteHandler("/var/tmp/production.sqlite")
handlers := make(map[string] interfaces.DbHandler)
handlers["DbUserRepo"] = dbHandler
handlers["DbCustomerRepo"] = dbHandler
handlers["DbItemRepo"] = dbHandler
handlers["DbOrderRepo"] = dbHandler
orderInteractor := new(usecases.OrderInteractor)
orderInteractor.UserRepository = interfaces.NewDbUserRepo(handlers)
orderInteractor.ItemRepository = interfaces.NewDbItemRepo(handlers)
orderInteractor.OrderRepository = interfaces.NewDbOrderRepo(handlers)
orderInteractor.Logger = new(infrastructure.Logger)
webserviceHandler := interfaces.WebserviceHandler{}
webserviceHandler.OrderInteractor = orderInteractor
http.HandleFunc("/orders", func(res http.ResponseWriter, req *http.Request) {
webserviceHandler.ShowOrder(res, req)
})
http.ListenAndServe(":8080", nil)
}