Created
March 16, 2016 23:43
-
-
Save stojg/bce3c1137873be9f33dd to your computer and use it in GitHub Desktop.
Sleep server, connects, but takes ages to respond
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
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