@@ -117,9 +117,7 @@ func {{ .HandlerInit }}(
117117 errhandler(ctx, w, err)
118118 }
119119 } else {
120- if f, ok := w. (http.Flusher ); ok {
121- f.Flush ()
122- }
120+ http.NewResponseController (w).Flush ()
123121 panic(http.ErrAbortHandler ) // too late to write an error
124122 }
125123 }
@@ -140,9 +138,7 @@ func {{ .HandlerInit }}(
140138 return
141139 }
142140 if _, err := io.Copy (w, buf); err != nil {
143- if f, ok := w. (http.Flusher ); ok {
144- f.Flush ()
145- }
141+ http.NewResponseController (w).Flush ()
146142 panic(http.ErrAbortHandler ) // too late to write an error
147143 }
148144 {{- else }}
@@ -255,9 +251,7 @@ func {{ .HandlerInit }}(
255251 errhandler(ctx, w, err)
256252 }
257253 } else {
258- if f, ok := w. (http.Flusher ); ok {
259- f.Flush ()
260- }
254+ http.NewResponseController (w).Flush ()
261255 panic(http.ErrAbortHandler ) // too late to write an error
262256 }
263257 }
@@ -284,9 +278,7 @@ func {{ .HandlerInit }}(
284278 {{- end }}
285279 {{- if .Method.SkipResponseBodyEncodeDecode }}
286280 if _, err := io.Copy (w, buf); err != nil {
287- if f, ok := w. (http.Flusher ); ok {
288- f.Flush ()
289- }
281+ http.NewResponseController (w).Flush ()
290282 panic(http.ErrAbortHandler ) // too late to write an error
291283 }
292284 {{- end }}
0 commit comments