Add proper error handling

This commit is contained in:
Eliot Whalan 2016-06-11 12:22:22 +10:00
parent e7c0922d7f
commit 1c83f69879

View File

@ -66,7 +66,8 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, text)
}
case "POST":
buf, _ := ioutil.ReadAll(r.Body)
buf, err := ioutil.ReadAll(r.Body)
check(err)
io.WriteString(w, address+save(buf)+"\n")
case "DELETE":
// Remove the record.
@ -75,6 +76,7 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) {
func main() {
http.HandleFunc("/", pasteHandler)
http.ListenAndServe(":8080", nil)
err := http.ListenAndServe(":8080", nil)
check(err)
}