Return error message when creating entry failed

kcoram/uplift
Jan-Lukas Else 2019-11-07 11:44:52 +01:00
父節點 7c07e4fdd9
當前提交 eb81344036
共有 1 個文件被更改,包括 6 次插入2 次删除

查看文件

@ -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")) {