Let a handler flush or set a write deadline through the access log and metrics (closes #191)
check / check (push) Successful in 3m15s

The access log's response writer had no Unwrap method, so
http.ResponseController stopped at it and a handler's Flush or
SetWriteDeadline returned http.ErrNotSupported. It now has one.

With metrics on, the metrics library's std.Handler put a writer of its
own in the chain with the same gap. The Metrics middleware now calls
the library's Measure with a writer of ours that has Unwrap, and keeps
its place in the chain.

A new test sets a write deadline and flushes through the production
router over a real connection, with metrics off and on, on a global
route and in an admin page route group.

Model: opus-5-5
This commit is contained in:
2026-10-02 10:30:50 +00:00
parent 287e47df7f
commit 11a34d498d
4 changed files with 186 additions and 14 deletions
+7
View File
@@ -233,6 +233,13 @@ func (lrw *loggingResponseWriter) WriteHeader(code int) {
lrw.ResponseWriter.WriteHeader(code)
}
// Unwrap lets http.ResponseController reach the writer underneath, so
// a handler can still flush or set a write deadline through the access
// log.
func (lrw *loggingResponseWriter) Unwrap() http.ResponseWriter {
return lrw.ResponseWriter
}
// concreteLogURL renders the request's own URL for the access log
// branches that keep it, with the query string replaced by a fixed
// marker.