Reader wraps a Reader interface and minifies the stream. Errors from the minifier are returned by the reader.
(mediatype string, r io.Reader)
| 249 | // Reader wraps a Reader interface and minifies the stream. |
| 250 | // Errors from the minifier are returned by the reader. |
| 251 | func (m *M) Reader(mediatype string, r io.Reader) io.Reader { |
| 252 | pr, pw := io.Pipe() |
| 253 | go func() { |
| 254 | if err := m.Minify(mediatype, pw, r); err != nil { |
| 255 | pw.CloseWithError(err) |
| 256 | } else { |
| 257 | pw.Close() |
| 258 | } |
| 259 | }() |
| 260 | return pr |
| 261 | } |
| 262 | |
| 263 | // writer makes sure that errors from the minifier are passed down through Close (can be blocking). |
| 264 | type writer struct { |