Skip to content

Instantly share code, notes, and snippets.

@arxdsilva
Created June 5, 2019 17:39
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 arxdsilva/a23aa9fec6a17a7cf66f8bde55d534c9 to your computer and use it in GitHub Desktop.
Save arxdsilva/a23aa9fec6a17a7cf66f8bde55d534c9 to your computer and use it in GitHub Desktop.
fake server golang
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