fix: 去除非前端操作记录操作日志

This commit is contained in:
TsMask
2023-11-01 15:49:35 +08:00
parent ac4d08d0a7
commit 5d8ebf413c
2 changed files with 9 additions and 2 deletions

View File

@@ -34,6 +34,13 @@ func LogOperate(options collectlogs.Options) func(http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
startTime := time.Now()
// 只对前端发送的数据进行记录
appCodeStr := r.Header.Get("X-App-Code")
if appCodeStr == "" {
next.ServeHTTP(w, r)
return
}
// 函数名
funcName := runtime.FuncForPC(reflect.ValueOf(next).Pointer()).Name()
lastDotIndex := strings.LastIndex(funcName, "/")