Add proper error handling

This commit is contained in:
Eliot Whalan 2016-06-11 12:22:22 +10:00
parent e7c0922d7f
commit 1c83f69879
1 changed files with 4 additions and 2 deletions

View File

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