Exemplo n.º 1
0
func Example_http() {
	hdlr := func(w http.ResponseWriter, req *http.Request) error {
		return ehttp.NewErrorf(http.StatusTeapot, "fail")
	}
	http.HandleFunc("/", ehttp.MWError(hdlr))
	log.Fatal(http.ListenAndServe(":8080", nil))
}
Exemplo n.º 2
0
func Example_gorilla() {
	hdlr := func(w http.ResponseWriter, req *http.Request) error {
		return ehttp.NewErrorf(http.StatusTeapot, "fail")
	}
	router := mux.NewRouter()
	router.HandleFunc("/", ehttp.MWError(hdlr))
	log.Fatal(http.ListenAndServe(":8080", router))
}