mirror of
https://github.com/axllent/mailpit.git
synced 2026-06-27 22:46:09 +00:00
Fix: Handle MaxBytesError in SendMessageHandler and return JSON error response
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user