I am using CloseNotifier in my application, in a code that looks like this
func Handler(res http.ResonseWriter, req *http.Request) {
notify := res.(CloseNotifier).CloseNotify()
someLogic();
select {
case <-notify:
someCleanup()
return;
default:
}
someOtherLogic();
}
I have noticed CloseNotifier is now deprecated. From source code:
// Deprecated: the CloseNotifier interface predates Go's context package.
// New code should use Request.Context instead.
However, I am not sure how to use Request.Context exactly here.