changeset 341:889517f254f5

Use code of JSONError as HTTP code.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 06 Aug 2018 12:36:20 +0200
parents 4c211ad5349e
children c6bd6ed18942
files controllers/json.go
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/controllers/json.go	Sun Aug 05 15:48:36 2018 +0200
+++ b/controllers/json.go	Mon Aug 06 12:36:20 2018 +0200
@@ -74,7 +74,10 @@
 			}
 		case JSONError:
 			rw.Header().Set("Content-Type", "application/json")
-			rw.WriteHeader(http.StatusInternalServerError)
+			if e.Code == 0 {
+				e.Code = http.StatusInternalServerError
+			}
+			rw.WriteHeader(e.Code)
 			var res = struct {
 				Message string `json:"message"`
 			}{