Feature Description
Summary
The http.CloseNotifier interface has been officially deprecated since Go 1.11.
Gin's Stream method currently calls w.CloseNotify() directly, and the ResponseWriter
interface embeds http.CloseNotifier. This change replaces it with Request.Context().Done(),
which is the recommended approach in the Go standard library.
Motivation
The Go documentation states the following about http.CloseNotifier:
Deprecated: the CloseNotifier interface predates Go's context package.
New code should use Request.Context instead.
Continuing to use http.CloseNotifier may trigger deprecation warnings and risks breakage
if it is eventually removed from the standard library.
Additionally, Request.Context().Done() covers a broader set of termination scenarios,
including context timeout and cancellation, not just client disconnection.
Feature Description
Summary
The
http.CloseNotifierinterface has been officially deprecated since Go 1.11.Gin's
Streammethod currently callsw.CloseNotify()directly, and theResponseWriterinterface embeds
http.CloseNotifier. This change replaces it withRequest.Context().Done(),which is the recommended approach in the Go standard library.
Motivation
The Go documentation states the following about
http.CloseNotifier:Continuing to use
http.CloseNotifiermay trigger deprecation warnings and risks breakageif it is eventually removed from the standard library.
Additionally,
Request.Context().Done()covers a broader set of termination scenarios,including context timeout and cancellation, not just client disconnection.