diff --git a/api.go b/api.go index 9197b0c..f068514 100644 --- a/api.go +++ b/api.go @@ -56,6 +56,14 @@ func put(w http.ResponseWriter, req *http.Request) { if *verbose { log.Printf("incoming: '%s'", body) } + // XXX: I am going to posit that there is something funky with how I write + // the error out below; If I don't check this, and I get to the + // JSONError{err.Error()} below then the app panics. + if string(body) == "" { + b, _ := json.Marshal(JSONError{"empty body"}) + http.Error(w, string(b), http.StatusMethodNotAllowed) + return + } parse_err := json.Unmarshal(body, &message) if parse_err != nil { b, _ := json.Marshal(JSONError{err.Error()})