Skip to content

Instantly share code, notes, and snippets.

@plutov
Created October 5, 2017 02:01
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 plutov/349edb5ce77d62b673b267e468ae1d0f to your computer and use it in GitHub Desktop.
Save plutov/349edb5ce77d62b673b267e468ae1d0f to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/500", func(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(500)
res.Write([]byte("NOT-OK"))
})
go http.ListenAndServe(":8080", nil)
res, err := http.Get("http://127.0.0.1:8080/500")
if err != nil {
log.Fatal(err)
}
fmt.Printf("res.StatusCode: %d\n", res.StatusCode)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment