Created
June 5, 2019 17:39
-
-
Save arxdsilva/a23aa9fec6a17a7cf66f8bde55d534c9 to your computer and use it in GitHub Desktop.
fake server golang
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" | |
"net/http" | |
"time" | |
) | |
func main() { | |
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
http.Error(w, "some err", http.StatusBadRequest) | |
}) | |
http.HandleFunc("/timeout", func(w http.ResponseWriter, r *http.Request) { | |
fmt.Println("request received: ", r.Method) | |
time.Sleep(3 * time.Second) | |
http.Error(w, "some err", http.StatusBadRequest) | |
}) | |
http.ListenAndServe(":3333", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment