mirror of
https://github.com/labstack/echo.git
synced 2024-11-24 08:22:21 +02:00
add supprt for go1.20 http.rwUnwrapper
This commit is contained in:
parent
c0bc886b78
commit
a7802ea523
@ -94,6 +94,13 @@ func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
|||||||
return r.Writer.(http.Hijacker).Hijack()
|
return r.Writer.(http.Hijacker).Hijack()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unwrap returns the original http.ResponseWriter.
|
||||||
|
// ResponseController can be used to access the original http.ResponseWriter.
|
||||||
|
// See [https://go.dev/blog/go1.20]
|
||||||
|
func (r *Response) Unwrap() http.ResponseWriter {
|
||||||
|
return r.Writer
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Response) reset(w http.ResponseWriter) {
|
func (r *Response) reset(w http.ResponseWriter) {
|
||||||
r.beforeFuncs = nil
|
r.beforeFuncs = nil
|
||||||
r.afterFuncs = nil
|
r.afterFuncs = nil
|
||||||
|
@ -72,3 +72,11 @@ func TestResponse_ChangeStatusCodeBeforeWrite(t *testing.T) {
|
|||||||
|
|
||||||
assert.Equal(t, http.StatusOK, rec.Code)
|
assert.Equal(t, http.StatusOK, rec.Code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestResponse_Unwrap(t *testing.T) {
|
||||||
|
e := New()
|
||||||
|
rec := httptest.NewRecorder()
|
||||||
|
res := &Response{echo: e, Writer: rec}
|
||||||
|
|
||||||
|
assert.Equal(t, rec, res.Unwrap())
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user