Created
January 4, 2017 15:19
-
-
Save paulja/fbe24b03dd2ec1a21077244a318f68a5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
"log" | |
"net/http" | |
"strconv" | |
"time" | |
) | |
func main() { | |
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { | |
// tarpit | |
t := req.URL.Query().Get("t") | |
if t != "" { | |
d, _ := time.ParseDuration(t) | |
time.Sleep(d) | |
} | |
// status code | |
s := req.URL.Query().Get("s") | |
if s != "" { | |
c, _ := strconv.Atoi(s) | |
w.WriteHeader(c) | |
} | |
fmt.Fprintf(w, "Web Request: %s\n", req.URL.String()) | |
}) | |
log.Fatal(http.ListenAndServe(":8080", nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment