This commit is contained in:
2025-03-18 07:43:46 +08:00
commit d2e93a2736
26 changed files with 918 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
package middleware
import (
"log"
"net/http"
"time"
)
// 审计日志中间件
func AuditLog(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
next.ServeHTTP(w, r)
log.Printf(
"Method=%s Path=%s Duration=%s",
r.Method,
r.URL.Path,
time.Since(start),
)
})
}