You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.4 KiB
59 lines
1.4 KiB
package route
|
|
|
|
import (
|
|
"key_performance_indicators/apirouter"
|
|
"key_performance_indicators/identification/interceptor"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
//初始化主路由
|
|
func InitialRouter() *gin.Engine {
|
|
var router = gin.Default()
|
|
|
|
//app默认相应
|
|
appLoadRouterGroup := router.Group("")
|
|
{
|
|
|
|
// 跨域设置
|
|
// router.Use(middleware.CrossDomainRequest()) // 如需跨域可以打开
|
|
//app默认相应
|
|
appLoadRouterGroup.GET("/", func(c *gin.Context) {
|
|
c.JSON(0, "通讯成功!")
|
|
})
|
|
appLoadRouterGroup.POST("/", func(c *gin.Context) {
|
|
c.JSON(0, "通讯成功!")
|
|
})
|
|
//实验路由
|
|
shiyanApi := apirouter.RouterGroupEntry.ShiyanApi
|
|
{
|
|
shiyanApi.RouterGroup(appLoadRouterGroup)
|
|
}
|
|
//OAuth 2.0 授权
|
|
oAuthEmpowerApi := apirouter.RouterGroupEntry.EmpowerRouter
|
|
{
|
|
oAuthEmpowerApi.RouterGroup(appLoadRouterGroup)
|
|
}
|
|
//登录验证
|
|
loginVerifyApi := apirouter.RouterGroupEntry.VerifyLogin
|
|
{
|
|
loginVerifyApi.RouterGroup(appLoadRouterGroup)
|
|
}
|
|
}
|
|
|
|
//验证身份接口
|
|
VerifyIdentity := router.Group("")
|
|
VerifyIdentity.Use(interceptor.AuthenticateUser()).Use(interceptor.VerifyUrl())
|
|
{
|
|
//v1版本接口
|
|
version1Api := apirouter.RouterGroupEntry.HonorsSouteRouter
|
|
version1Api.RouterGroup(VerifyIdentity)
|
|
}
|
|
//Token身份验证
|
|
VerifyIdentityToken := router.Group("")
|
|
VerifyIdentityToken.Use(interceptor.IdentificationToken())
|
|
{
|
|
|
|
}
|
|
return router
|
|
}
|
|
|