Skip to content

Instantly share code, notes, and snippets.

@najamsk
Created November 8, 2022 07:46
Show Gist options
  • Save najamsk/7ec97d0a155653eed74c9fdcbf58a3a9 to your computer and use it in GitHub Desktop.
Save najamsk/7ec97d0a155653eed74c9fdcbf58a3a9 to your computer and use it in GitHub Desktop.
gorilla streaming response
func StreamHandler(w http.ResponseWriter, r *http.Request) {
log.Println("string handler invoked")
for i := 0; i < 15000; i++ {
w.Write([]byte("Gorilla! \n"))
w.(http.Flusher).Flush()
time.Sleep(1 * time.Second)
// time.Sleep(1 * time.Second)
}
fmt.Println("done")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment