NewResponseRecorder returns a new ResponseRecorder that can be used instead of a standard http.ResponseWriter. The recorder is useful for middlewares which need to buffer a response and potentially process its entire body before actually writing the response to the underlying writer. Of course, buff
(w http.ResponseWriter, buf *bytes.Buffer, shouldBuffer ShouldBufferFunc)
| 135 | // because they are not the final response; they are passed through |
| 136 | // directly to the underlying ResponseWriter. |
| 137 | func NewResponseRecorder(w http.ResponseWriter, buf *bytes.Buffer, shouldBuffer ShouldBufferFunc) ResponseRecorder { |
| 138 | return &responseRecorder{ |
| 139 | ResponseWriterWrapper: &ResponseWriterWrapper{ResponseWriter: w}, |
| 140 | buf: buf, |
| 141 | shouldBuffer: shouldBuffer, |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | // WriteHeader writes the headers with statusCode to the wrapped |
| 146 | // ResponseWriter unless the response is to be buffered instead. |
no outgoing calls