WrapWriter wraps an http.ResponseWriter, returning a proxy that allows you to hook into various parts of the response process.
(w http.ResponseWriter)
| 30 | // WrapWriter wraps an http.ResponseWriter, returning a proxy that allows you to |
| 31 | // hook into various parts of the response process. |
| 32 | func WrapWriter(w http.ResponseWriter) WriterProxy { |
| 33 | _, cn := w.(http.CloseNotifier) |
| 34 | _, fl := w.(http.Flusher) |
| 35 | _, hj := w.(http.Hijacker) |
| 36 | _, rf := w.(io.ReaderFrom) |
| 37 | |
| 38 | bw := basicWriter{ResponseWriter: w} |
| 39 | if cn && fl && hj && rf { |
| 40 | return &fancyWriter{bw} |
| 41 | } |
| 42 | if fl { |
| 43 | return &flushWriter{bw} |
| 44 | } |
| 45 | return &bw |
| 46 | } |
| 47 | |
| 48 | // basicWriter wraps a http.ResponseWriter that implements the minimal |
| 49 | // http.ResponseWriter interface. |