Last active
March 15, 2017 05:33
-
-
Save AndreKR/b0d2dc63749a9e9162853fd058129e39 to your computer and use it in GitHub Desktop.
Detecting client closed connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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