I do have implemented a Server Sent Event broker that relies on http.CloseNotifier CloseNotify to close le connection. But it is deprecated!
I try to figure out how to implement the de-connection using Request.Context instead of http.CloseNotifier
My code with the CloseNotifier, simply returns on notification :
// Listen to connection close and un-register messageChan
notify := w.(http.CloseNotifier).CloseNotify()
for {
select {
case <-notify:
return
default:
// On message
commands := <-messageChan
Can i simply replace the notify channel by the Done channel?
done := r.Context().Done()
for {
select {
case <-done:
return
default:
...
I’m new to Go Land and i’m not sure to understand completely the notion of “http.context”.