Closed leizor closed 1 year ago
It looks to me like this method will advertise the possibility of Flush()
on writers that don't support it.
Even though there is a disclaimer, this could break something. Hyram's Law.
What about this: create a struct embedding badResponseLoggingWriter
that implements Flusher
, and select which one to create in newBadResponseLoggingWriter
.
I like that much better - will do!
@bboreham I think this is ready for a second look
This PR adds
Flush()
to themiddleware.badResponseLoggingWriter
, making it implementhttp.Flusher
.I think, ideally, none of this middleware should interfere with what the ultimate HTTP handlers want to try to do. Making a best-effort attempt at
Flush()
seems like the friendliest behavior for middleware; if it can flush, great, otherwise nothing happens.Additionally, I think this best-effort type behavior plays nicely with this disclaimer about
http.Flusher
: