mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 10:09:54 +08:00
更新2.1.2版本,优化部门、角色权限,增加上下级关系;增加登录、系统、短信日志;优化省市区编码
This commit is contained in:
@@ -37,7 +37,8 @@ func New() *sMiddleware {
|
||||
return &sMiddleware{
|
||||
LoginUrl: "/common",
|
||||
DemoWhiteList: g.Map{
|
||||
"/admin/site/login": struct{}{}, // 后台登录
|
||||
"/admin/site/login": struct{}{}, // 后台登录
|
||||
"/admin/genCodes/preview": struct{}{}, // 预览代码
|
||||
},
|
||||
}
|
||||
}
|
||||
|
23
server/internal/logic/middleware/limit_blacklist.go
Normal file
23
server/internal/logic/middleware/limit_blacklist.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"hotgo/internal/global"
|
||||
"hotgo/internal/library/location"
|
||||
"hotgo/internal/library/response"
|
||||
)
|
||||
|
||||
// Blacklist IP黑名单限制中间件
|
||||
func (s *sMiddleware) Blacklist(r *ghttp.Request) {
|
||||
if global.Blacklists != nil {
|
||||
if _, ok := global.Blacklists[location.GetClientIp(r)]; ok {
|
||||
response.JsonExit(r, gcode.CodeServerBusy.Code(), "请求异常,已被封禁,如有疑问请联系管理员!")
|
||||
}
|
||||
} else {
|
||||
g.Log().Warningf(r.Context(), "blacklists uninitialized")
|
||||
}
|
||||
|
||||
r.Middleware.Next()
|
||||
}
|
@@ -42,14 +42,14 @@ func (s *sMiddleware) ResponseHandler(r *ghttp.Request) {
|
||||
|
||||
if err = r.GetError(); err != nil {
|
||||
// 记录到自定义错误日志文件
|
||||
g.Log("exception").Print(ctx, "exception:", err)
|
||||
g.Log().Warningf(ctx, "exception:%v", err)
|
||||
|
||||
code = gerror.Code(err).Code()
|
||||
message = err.Error()
|
||||
|
||||
// 是否输出错误到页面
|
||||
if g.Cfg().MustGet(ctx, "hotgo.debug", true).Bool() {
|
||||
data = charset.GetStack(err)
|
||||
data = charset.ParseErrStack(err)
|
||||
}
|
||||
} else {
|
||||
data = r.GetHandlerResponse()
|
||||
|
Reference in New Issue
Block a user