Fix: Handle MaxBytesError in SendMessageHandler and return JSON error response

This commit is contained in:
Ralph Slooten
2026-06-27 21:16:30 +12:00
parent acad7f4806
commit 9d09cb1e28

View File

@@ -54,7 +54,10 @@ func SendMessageHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
var maxErr *http.MaxBytesError
if errors.As(err, &maxErr) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusRequestEntityTooLarge)
_ = json.NewEncoder(w).Encode(struct{ Error string }{Error: err.Error()})
return
}
httpJSONError(w, err.Error())
return