func Example_httpPanic() { hdlr := func(w http.ResponseWriter, req *http.Request) error { panic(ehttp.NewErrorf(http.StatusTeapot, "big fail")) } http.HandleFunc("/", ehttp.MWErrorPanic(hdlr)) log.Fatal(http.ListenAndServe(":8080", nil)) }
func Example_gorillaPanic() { hdlr := func(w http.ResponseWriter, req *http.Request) error { panic(ehttp.NewErrorf(http.StatusTeapot, "big fail")) } router := mux.NewRouter() router.HandleFunc("/", ehttp.MWErrorPanic(hdlr)) log.Fatal(http.ListenAndServe(":8080", router)) }