2022-05-18 17:57:03 +08:00
|
|
|
package routes
|
|
|
|
|
|
|
|
import (
|
2022-05-29 10:06:21 +08:00
|
|
|
"github.com/eryajf/go-ldap-admin/controller"
|
|
|
|
"github.com/eryajf/go-ldap-admin/middleware"
|
2022-05-18 17:57:03 +08:00
|
|
|
|
|
|
|
jwt "github.com/appleboy/gin-jwt/v2"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
func InitApiRoutes(r *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) gin.IRoutes {
|
|
|
|
api := r.Group("/api")
|
|
|
|
// 开启jwt认证中间件
|
|
|
|
api.Use(authMiddleware.MiddlewareFunc())
|
|
|
|
// 开启casbin鉴权中间件
|
|
|
|
api.Use(middleware.CasbinMiddleware())
|
|
|
|
{
|
|
|
|
api.GET("/tree", controller.Api.GetTree)
|
|
|
|
api.GET("/list", controller.Api.List)
|
|
|
|
api.POST("/add", controller.Api.Add)
|
|
|
|
api.POST("/update", controller.Api.Update)
|
|
|
|
api.POST("/delete", controller.Api.Delete)
|
|
|
|
}
|
|
|
|
|
|
|
|
return r
|
|
|
|
}
|