Return error message when creating entry failed

kcoram/uplift
Jan-Lukas Else 2019-11-07 11:44:52 +01:00
parent 7c07e4fdd9
commit eb81344036
1 changed files with 6 additions and 2 deletions

View File

@ -44,9 +44,13 @@ func handleMicroPub(w http.ResponseWriter, r *http.Request) {
}
bodyString := string(bodyBytes)
entry, err := CreateEntry(contentType, bodyString)
if entry == nil {
if err != nil || entry == nil {
w.WriteHeader(http.StatusBadRequest)
if err != nil {
_, _ = w.Write([]byte(err.Error()))
} else {
_, _ = w.Write([]byte("There was an error creating the entry"))
}
return
}
if CheckAuthorization(entry, r.Header.Get("authorization")) {