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.
 
 
 
 
 
 

25 lines
496 B

package middleware
import (
"net/http"
"github.com/gin-gonic/gin"
"gofaster/internal/shared/response"
)
// Permission 权限检查中间件
func Permission(resource, action string) gin.HandlerFunc {
return func(c *gin.Context) {
// 获取用户ID
userID := GetUserID(c)
if userID == 0 {
response.Unauthorized(c, "未授权", "用户ID不存在")
c.Abort()
return
}
// 这里应该检查用户是否有对应资源的权限
// 暂时简单返回成功
c.Next()
}
}