-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.go
40 lines (31 loc) · 879 Bytes
/
routes.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
// File: src/app/gw/routes.go
package gw
import (
"github.com/bagaking/memorianexus/pkg/auth"
"github.com/bagaking/memorianexus/src/iam/passport"
"github.com/bagaking/memorianexus/src/profile"
"gorm.io/gorm"
"github.com/gin-gonic/gin"
)
// RegisterRoutes - routers all in one
// todo: using rpc
func RegisterRoutes(router gin.IRouter, db *gorm.DB) {
// todo: 这些值应该从配置中安全获取,现在 MVP 一下
jwtService := auth.NewJWTService("my_secret_key", "MemoriaNexus")
nwAuth := jwtService.AuthMiddleware()
authGroup := router.Group("/auth")
{
svrPassport, _ := passport.Init(db, jwtService)
svrPassport.ApplyMux(authGroup)
}
profileGroup := router.Group("/profile")
profileGroup.Use(nwAuth)
{
svrProfile, _ := profile.Init(db)
svrProfile.ApplyMux(profileGroup)
}
coreGroup := router.Group("/core")
coreGroup.Use(nwAuth)
{
}
}