body_cleanup.go 387 B

123456789101112131415161718
  1. package middleware
  2. import (
  3. "github.com/QuantumNous/new-api/common"
  4. "github.com/gin-gonic/gin"
  5. )
  6. // BodyStorageCleanup 请求体存储清理中间件
  7. // 在请求处理完成后自动清理磁盘/内存缓存
  8. func BodyStorageCleanup() gin.HandlerFunc {
  9. return func(c *gin.Context) {
  10. // 处理请求
  11. c.Next()
  12. // 请求结束后清理存储
  13. common.CleanupBodyStorage(c)
  14. }
  15. }