mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-09 19:50:30 +08:00
访问日志搜索method:XXX和requestMethod:XXX方法
This commit is contained in:
@@ -460,6 +460,7 @@ func (this *HTTPAccessLogDAO) listAccessLogs(tx *dbs.Tx,
|
|||||||
var requestPathReg = regexp.MustCompile(`requestPath:(\S+)`)
|
var requestPathReg = regexp.MustCompile(`requestPath:(\S+)`)
|
||||||
var protoReg = regexp.MustCompile(`proto:(\S+)`)
|
var protoReg = regexp.MustCompile(`proto:(\S+)`)
|
||||||
var schemeReg = regexp.MustCompile(`scheme:(\S+)`)
|
var schemeReg = regexp.MustCompile(`scheme:(\S+)`)
|
||||||
|
var methodReg = regexp.MustCompile(`(?:method|requestMethod):(\S+)`)
|
||||||
|
|
||||||
var count = len(tableQueries)
|
var count = len(tableQueries)
|
||||||
var wg = &sync.WaitGroup{}
|
var wg = &sync.WaitGroup{}
|
||||||
@@ -607,6 +608,11 @@ func (this *HTTPAccessLogDAO) listAccessLogs(tx *dbs.Tx,
|
|||||||
query.Where("JSON_EXTRACT(content, '$.requestURI') LIKE :keyword").
|
query.Where("JSON_EXTRACT(content, '$.requestURI') LIKE :keyword").
|
||||||
Param("keyword", dbutils.QuoteLikePrefix("\""+u.RequestURI()))
|
Param("keyword", dbutils.QuoteLikePrefix("\""+u.RequestURI()))
|
||||||
}
|
}
|
||||||
|
} else if methodReg.MatchString(keyword) { // method|requestMethod:xxx
|
||||||
|
isSpecialKeyword = true
|
||||||
|
var matches = methodReg.FindStringSubmatch(keyword)
|
||||||
|
query.Where("JSON_EXTRACT(content, '$.requestMethod')=:keyword").
|
||||||
|
Param("keyword", strings.ToUpper(matches[1]))
|
||||||
}
|
}
|
||||||
if !isSpecialKeyword {
|
if !isSpecialKeyword {
|
||||||
if regexp.MustCompile(`^ip:.+`).MatchString(keyword) {
|
if regexp.MustCompile(`^ip:.+`).MatchString(keyword) {
|
||||||
|
|||||||
Reference in New Issue
Block a user