Skip to content

Commit f7ba509

Browse files
committed
feat(serverHandler/mutate): expose upload error to client
1 parent 04ed1ba commit f7ba509

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/serverHandler/mutate.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ func (h *handler) mutate(w http.ResponseWriter, r *http.Request, data *responseD
2727
header := w.Header()
2828
header.Set("Content-Type", "application/json; charset=utf-8")
2929
header.Set("Cache-Control", "public, max-age=0")
30-
w.WriteHeader(http.StatusOK)
3130

3231
if success {
32+
w.WriteHeader(http.StatusOK)
3333
w.Write([]byte(`{"success":true}`))
3434
} else {
35+
w.WriteHeader(http.StatusInternalServerError)
3536
w.Write([]byte(`{"success":false}`))
3637
}
3738
} else {
@@ -49,6 +50,11 @@ func (h *handler) mutate(w http.ResponseWriter, r *http.Request, data *responseD
4950
reqPath += ctxQs
5051
}
5152
}
52-
http.Redirect(w, r, reqPath, http.StatusFound)
53+
54+
if success {
55+
http.Redirect(w, r, reqPath, http.StatusFound)
56+
} else {
57+
w.WriteHeader(http.StatusInternalServerError)
58+
}
5359
}
5460
}

0 commit comments

Comments
 (0)