feat: add middleware.cache

This commit is contained in:
loveuer
2024-07-25 17:31:57 +08:00
parent cee0bfb43d
commit 53f124c9ec
5 changed files with 159 additions and 4 deletions

21
internal/model/writer.go Normal file
View File

@ -0,0 +1,21 @@
package model
import (
"bytes"
"github.com/loveuer/nf"
)
type CustomResponseWriter struct {
nf.ResponseWriter
Body *bytes.Buffer
}
func (w CustomResponseWriter) Write(b []byte) (int, error) {
w.Body.Write(b)
return w.ResponseWriter.Write(b)
}
func (w CustomResponseWriter) WriteString(s string) (int, error) {
w.Body.WriteString(s)
return w.ResponseWriter.WriteString(s)
}