UnwrapResponse unwraps given ResponseWriter to return contexts original Echo Response. rw has to implement following method `Unwrap() http.ResponseWriter`
(rw http.ResponseWriter)
| 118 | // UnwrapResponse unwraps given ResponseWriter to return contexts original Echo Response. rw has to implement |
| 119 | // following method `Unwrap() http.ResponseWriter` |
| 120 | func UnwrapResponse(rw http.ResponseWriter) (*Response, error) { |
| 121 | for { |
| 122 | switch t := rw.(type) { |
| 123 | case *Response: |
| 124 | return t, nil |
| 125 | case interface{ Unwrap() http.ResponseWriter }: |
| 126 | rw = t.Unwrap() |
| 127 | continue |
| 128 | default: |
| 129 | return nil, errors.New("ResponseWriter does not implement 'Unwrap() http.ResponseWriter' interface or unwrap to *echo.Response") |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | // delayedStatusWriter is a wrapper around http.ResponseWriter that delays writing the status code until first Write is called. |
| 135 | // This allows (global) error handler to decide correct status code to be sent to the client. |
searching dependent graphs…