jlelse
/
hugo-micropub
Archived
1
Fork 0

Return error message when creating entry failed

This commit is contained in:
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)
_, _ = w.Write([]byte("There was an error creating the entry"))
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")) {