mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-11-11 11:43:46 +08:00
发布v2.15.1版本,更新内容请查看:https://github.com/bufanyun/hotgo/blob/v2.0/docs/guide-zh-CN/start-update-log.md
This commit is contained in:
@@ -10,14 +10,19 @@ import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/service"
|
||||
"hotgo/utility/simple"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 忽略的请求方式
|
||||
var ignoredRequestMethods = []string{"HEAD", "PRI"}
|
||||
|
||||
// accessLog 访问日志
|
||||
func (s *sHook) accessLog(r *ghttp.Request) {
|
||||
if r.IsFileRequest() {
|
||||
if s.isIgnoredRequest(r) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -37,3 +42,15 @@ func (s *sHook) accessLog(r *ghttp.Request) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// isIgnoredRequest 是否忽略请求
|
||||
func (s *sHook) isIgnoredRequest(r *ghttp.Request) bool {
|
||||
if r.IsFileRequest() {
|
||||
return true
|
||||
}
|
||||
|
||||
if gstr.InArray(ignoredRequestMethods, strings.ToUpper(r.Method)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user