Skip to content

Commit

Permalink
add supprt for go1.20 http.rwUnwrapper to gin.responseWriter (#3489)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmdm authored Feb 12, 2023
1 parent bd82c9e commit c1d06e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions response_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ type responseWriter struct {

var _ ResponseWriter = (*responseWriter)(nil)

func (w *responseWriter) Unwrap() http.ResponseWriter {
return w.ResponseWriter
}

func (w *responseWriter) reset(writer http.ResponseWriter) {
w.ResponseWriter = writer
w.size = noWritten
Expand Down
6 changes: 6 additions & 0 deletions response_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ func init() {
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) {
testWriter := httptest.NewRecorder()
writer := &responseWriter{}
Expand Down

0 comments on commit c1d06e3

Please sign in to comment.