MiddlewareWithError provides a middleware function that minifies content on the fly by intercepting writes to http.ResponseWriter. The error function allows handling minification errors. http.ResponseWriter loses all functionality such as Pusher, Hijacker, Flusher, ... Minification might be slower t
(next http.Handler, errorFunc func(w http.ResponseWriter, r *http.Request, err error))
| 374 | // http.ResponseWriter loses all functionality such as Pusher, Hijacker, Flusher, ... |
| 375 | // Minification might be slower than just sending the original file! Caching is advised. |
| 376 | func (m *M) MiddlewareWithError(next http.Handler, errorFunc func(w http.ResponseWriter, r *http.Request, err error)) http.Handler { |
| 377 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 378 | mw := m.ResponseWriter(w, r) |
| 379 | next.ServeHTTP(mw, r) |
| 380 | if err := mw.Close(); err != nil { |
| 381 | errorFunc(w, r, err) |
| 382 | return |
| 383 | } |
| 384 | }) |
| 385 | } |
nothing calls this directly
no test coverage detected