forked from TrueCloudLab/frostfs-s3-gw
[#60] Implement flusher on all http.ResponseWriters
Signed-off-by: Alex Vanin <a.vanin@yadro.com>
This commit is contained in:
parent
cf18158da4
commit
43685e03d9
2 changed files with 12 additions and 0 deletions
|
@ -286,6 +286,12 @@ func (w *responseWrapper) Flush() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *writeCounter) Flush() {
|
||||||
|
if f, ok := w.ResponseWriter.(http.Flusher); ok {
|
||||||
|
f.Flush()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (w *writeCounter) Write(p []byte) (int, error) {
|
func (w *writeCounter) Write(p []byte) (int, error) {
|
||||||
n, err := w.ResponseWriter.Write(p)
|
n, err := w.ResponseWriter.Write(p)
|
||||||
atomic.AddUint64(&w.countBytes, uint64(n))
|
atomic.AddUint64(&w.countBytes, uint64(n))
|
||||||
|
|
|
@ -117,6 +117,12 @@ func (lrw *logResponseWriter) WriteHeader(code int) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (lrw *logResponseWriter) Flush() {
|
||||||
|
if f, ok := lrw.ResponseWriter.(http.Flusher); ok {
|
||||||
|
f.Flush()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func setRequestID(h http.Handler) http.Handler {
|
func setRequestID(h http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
// generate random UUIDv4
|
// generate random UUIDv4
|
||||||
|
|
Loading…
Reference in a new issue