Skip to content

Instantly share code, notes, and snippets.

@stojg
Created March 16, 2016 23:43
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 stojg/bce3c1137873be9f33dd to your computer and use it in GitHub Desktop.
Save stojg/bce3c1137873be9f33dd to your computer and use it in GitHub Desktop.
Sleep server, connects, but takes ages to respond
package main
import(
"fmt"
"net/http"
"log"
"time"
"flag"
)
func main() {
var timeout = flag.Int("timeout", 60, "how many seconds to sleep")
flag.Parse()
sleepDuration := time.Duration(*timeout) * time.Second
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
log.Printf("connected, will sleep for %s seconds\n", sleepDuration)
time.Sleep(sleepDuration)
fmt.Fprint(w, "Hello, i am very very slow")
log.Printf("responded\n")
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment