forked from mmuflih/go-arch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (29 loc) · 815 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
37
38
39
40
package main
import (
"fmt"
"github.com/mmuflih/go-di-arch/container"
"github.com/dgrijalva/jwt-go"
"github.com/mmuflih/go-di-arch/app"
"github.com/mmuflih/go-httplib/httplib"
)
import "go.uber.org/dig"
var _ = dig.Name
func main() {
myrole := make(map[string][]string)
myrole[app.ADMIN] = []string{app.ADMIN}
myrole[app.LEADER] = []string{app.LEADER, app.ADMIN}
myrole[app.USER] = []string{app.USER, app.LEADER, app.ADMIN}
httplib.InitJWTMiddlewareWithRole([]byte("Go-DI-arch"), jwt.SigningMethodHS512, myrole)
c := container.BuildContainer()
if err := c.Invoke(container.InvokeRoute); err != nil {
panic(err)
}
if err := c.Provide(container.NewRoute); err != nil {
panic(err)
}
if err := c.Invoke(func(s *container.ServerRoute) {
s.Run()
}); err != nil {
fmt.Println(err)
}
}