Middleware provides a middleware function that minifies content on the fly by intercepting writes to http.ResponseWriter. http.ResponseWriter loses all functionality such as Pusher, Hijacker, Flusher, ... Minification might be slower than just sending the original file! Caching is advised.
(next http.Handler)
| 363 | // http.ResponseWriter loses all functionality such as Pusher, Hijacker, Flusher, ... |
| 364 | // Minification might be slower than just sending the original file! Caching is advised. |
| 365 | func (m *M) Middleware(next http.Handler) http.Handler { |
| 366 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 367 | mw := m.ResponseWriter(w, r) |
| 368 | next.ServeHTTP(mw, r) |
| 369 | mw.Close() |
| 370 | }) |
| 371 | } |
| 372 | |
| 373 | // MiddlewareWithError provides a middleware function that minifies content on the fly by intercepting writes to http.ResponseWriter. The error function allows handling minification errors. |
| 374 | // http.ResponseWriter loses all functionality such as Pusher, Hijacker, Flusher, ... |