35 lines
618 B
Go
35 lines
618 B
Go
|
package model
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"io"
|
||
|
|
||
|
"github.com/loveuer/nf"
|
||
|
)
|
||
|
|
||
|
type CopyResponseWriter struct {
|
||
|
nf.ResponseWriter
|
||
|
buf *bytes.Buffer
|
||
|
}
|
||
|
|
||
|
func (w CopyResponseWriter) Write(b []byte) (int, error) {
|
||
|
w.buf.Write(b)
|
||
|
return w.ResponseWriter.Write(b)
|
||
|
}
|
||
|
|
||
|
func (w CopyResponseWriter) String() string {
|
||
|
return w.buf.String()
|
||
|
}
|
||
|
|
||
|
func (w CopyResponseWriter) Bytes() []byte {
|
||
|
return w.buf.Bytes()
|
||
|
}
|
||
|
|
||
|
func (w CopyResponseWriter) Reader() io.Reader {
|
||
|
return w.buf
|
||
|
}
|
||
|
|
||
|
func NewCopyWriter(w nf.ResponseWriter) *CopyResponseWriter {
|
||
|
return &CopyResponseWriter{buf: bytes.NewBuffer(make([]byte, 0, 1024)), ResponseWriter: w}
|
||
|
}
|