优化响应中间件,自动识别响应数据格式

This commit is contained in:
孟帅
2023-06-16 19:58:29 +08:00
parent 50e64e132f
commit 9b89402bf6
13 changed files with 112 additions and 128 deletions

View File

@@ -19,17 +19,17 @@ func (s *sMiddleware) Develop(r *ghttp.Request) {
}
if !gstr.InArray(ips, "*") {
cuIp := location.GetClientIp(r)
clientIp := location.GetClientIp(r)
ok := false
for _, ip := range ips {
if ip == cuIp {
if ip == clientIp {
ok = true
break
}
}
if !ok {
response.JsonExit(r, gcode.CodeNotSupported.Code(), fmt.Sprintf("当前IP[%s]没有配置生成白名单!", cuIp))
response.JsonExit(r, gcode.CodeNotSupported.Code(), fmt.Sprintf("当前IP[%s]没有配置生成白名单!", clientIp))
return
}
}