mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 10:09:54 +08:00
用户操作权限增加角色权限过滤,优化角色/部门关系树生成,修复验证码空参数不验证问题
This commit is contained in:
@@ -17,7 +17,6 @@ import (
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/global"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/library/response"
|
||||
@@ -27,12 +26,14 @@ import (
|
||||
"hotgo/utility/validate"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type sMiddleware struct {
|
||||
LoginUrl string // 登录路由地址
|
||||
DemoWhiteList g.Map // 演示模式放行的路由白名单
|
||||
FilterRoutes map[string]ghttp.RouterItem // 支持预处理的web路由
|
||||
routeMutex sync.Mutex
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -52,7 +53,7 @@ func NewMiddleware() *sMiddleware {
|
||||
|
||||
// Ctx 初始化请求上下文
|
||||
func (s *sMiddleware) Ctx(r *ghttp.Request) {
|
||||
if global.JaegerSwitch {
|
||||
if g.Cfg().MustGet(r.Context(), "jaeger.switch").Bool() {
|
||||
ctx, span := gtrace.NewSpan(r.Context(), "middleware.ctx")
|
||||
span.SetAttributes(attribute.KeyValue{
|
||||
Key: "traceID",
|
||||
|
@@ -13,6 +13,13 @@ import (
|
||||
func (s *sMiddleware) GetFilterRoutes(r *ghttp.Request) map[string]ghttp.RouterItem {
|
||||
// 首次访问时加载
|
||||
if s.FilterRoutes == nil {
|
||||
s.routeMutex.Lock()
|
||||
defer s.routeMutex.Unlock()
|
||||
|
||||
if s.FilterRoutes != nil {
|
||||
return s.FilterRoutes
|
||||
}
|
||||
|
||||
s.FilterRoutes = make(map[string]ghttp.RouterItem)
|
||||
for _, v := range r.Server.GetRoutes() {
|
||||
// 非规范路由不加载
|
||||
|
Reference in New Issue
Block a user