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), ) }) }