Feat: User/Me

This commit is contained in:
HFO4
2019-11-12 15:34:54 +08:00
parent 80f30465e9
commit 589c399488
9 changed files with 148 additions and 17 deletions

View File

@@ -7,11 +7,13 @@ import (
"github.com/gin-gonic/gin"
)
// InitRouter 初始化路由
func InitRouter() *gin.Engine {
r := gin.Default()
// 中间件
r.Use(middleware.Session(conf.SystemConfig.SessionSecret))
r.Use(middleware.CurrentUser())
// 顶层路由分组
v3 := r.Group("/Api/V3")
@@ -21,6 +23,19 @@ func InitRouter() *gin.Engine {
// 用户登录
v3.POST("User/Session", controllers.UserLogin)
// 需要登录保护的
auth := v3.Group("")
auth.Use(middleware.AuthRequired())
{
// 用户类
user := auth.Group("User")
{
// 当前登录用户信息
user.GET("Me", controllers.UserMe)
}
}
}
return r
}