mirror of https://github.com/gin-gonic/gin.git
add supprt for go1.20 http.rwUnwrapper to gin.responseWriter (#3489)
This commit is contained in:
parent
bd82c9e351
commit
c1d06e3d08
|
@ -51,6 +51,10 @@ type responseWriter struct {
|
||||||
|
|
||||||
var _ ResponseWriter = (*responseWriter)(nil)
|
var _ ResponseWriter = (*responseWriter)(nil)
|
||||||
|
|
||||||
|
func (w *responseWriter) Unwrap() http.ResponseWriter {
|
||||||
|
return w.ResponseWriter
|
||||||
|
}
|
||||||
|
|
||||||
func (w *responseWriter) reset(writer http.ResponseWriter) {
|
func (w *responseWriter) reset(writer http.ResponseWriter) {
|
||||||
w.ResponseWriter = writer
|
w.ResponseWriter = writer
|
||||||
w.size = noWritten
|
w.size = noWritten
|
||||||
|
|
|
@ -30,6 +30,12 @@ func init() {
|
||||||
SetMode(TestMode)
|
SetMode(TestMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestResponseWriterUnwrap(t *testing.T) {
|
||||||
|
testWriter := httptest.NewRecorder()
|
||||||
|
writer := &responseWriter{ResponseWriter: testWriter}
|
||||||
|
assert.Same(t, testWriter, writer.Unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
func TestResponseWriterReset(t *testing.T) {
|
func TestResponseWriterReset(t *testing.T) {
|
||||||
testWriter := httptest.NewRecorder()
|
testWriter := httptest.NewRecorder()
|
||||||
writer := &responseWriter{}
|
writer := &responseWriter{}
|
||||||
|
|
Loading…
Reference in New Issue