Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Detecting client closed connection
func handleRequest(w http.ResponseWriter, r *http.Request) {
cn := w.(http.CloseNotifier)
cc := cn.CloseNotify()
go func() {
<-cc
log.Println("Closed!")
}()
time.Sleep(5 * time.Second)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment