Skip to content

Instantly share code, notes, and snippets.

@AndreKR
Last active March 15, 2017 05:33
Show Gist options
  • Save AndreKR/b0d2dc63749a9e9162853fd058129e39 to your computer and use it in GitHub Desktop.
Save AndreKR/b0d2dc63749a9e9162853fd058129e39 to your computer and use it in GitHub Desktop.
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