Skip to content

Commit c1d06e3

Browse files
authored
add supprt for go1.20 http.rwUnwrapper to gin.responseWriter (#3489)
1 parent bd82c9e commit c1d06e3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

response_writer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ type responseWriter struct {
5151

5252
var _ ResponseWriter = (*responseWriter)(nil)
5353

54+
func (w *responseWriter) Unwrap() http.ResponseWriter {
55+
return w.ResponseWriter
56+
}
57+
5458
func (w *responseWriter) reset(writer http.ResponseWriter) {
5559
w.ResponseWriter = writer
5660
w.size = noWritten

response_writer_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ func init() {
3030
SetMode(TestMode)
3131
}
3232

33+
func TestResponseWriterUnwrap(t *testing.T) {
34+
testWriter := httptest.NewRecorder()
35+
writer := &responseWriter{ResponseWriter: testWriter}
36+
assert.Same(t, testWriter, writer.Unwrap())
37+
}
38+
3339
func TestResponseWriterReset(t *testing.T) {
3440
testWriter := httptest.NewRecorder()
3541
writer := &responseWriter{}

0 commit comments

Comments
 (0)