Skip to content

Instantly share code, notes, and snippets.

@Poincare
Created December 12, 2013 04:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Poincare/7923366 to your computer and use it in GitHub Desktop.
Save Poincare/7923366 to your computer and use it in GitHub Desktop.
package main
import (
"github.com/hoisie/web"
"net/http"
"strconv"
"time"
)
func hello(ctx *web.Context, num string) {
flusher, _ := ctx.ResponseWriter.(http.Flusher)
flusher.Flush()
n, _ := strconv.ParseInt(num, 10, 64)
for i := int64(0); i < n; i++ {
ctx.WriteString("<br>hello world</br>")
flusher.Flush()
time.Sleep(1e9)
}
}
func main() {
web.Get("/([0-9]+)", hello)
web.Run("0.0.0.0:9999")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment