fix: add flush to support chunked for the metric middleware (#2772)

Signed-off-by: saltbo <saltbo@foxmail.com>
This commit is contained in:
Ambor
2023-04-11 08:40:58 +05:30
committed by GitHub
parent 117c383fac
commit 32530ac474
2 changed files with 104 additions and 0 deletions
+6
View File
@@ -67,6 +67,12 @@ func (rw *ResponseWriterWrapper) WriteHeader(statuscode int) {
rw.ResponseWriter.WriteHeader(statuscode)
}
func (rw *ResponseWriterWrapper) Flush() {
if f, ok := rw.ResponseWriter.(http.Flusher); ok {
f.Flush()
}
}
func HTTPMetricMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if util.IsWebsocketRequest(r) {