changeset 238:2b39bf2bf1fd

If no error code was given in a JSONResult assume Status OK (200).
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 26 Jul 2018 17:09:43 +0200
parents 3771788d3dae
children 713234a04a87
files controllers/json.go
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/controllers/json.go	Thu Jul 26 17:07:03 2018 +0200
+++ b/controllers/json.go	Thu Jul 26 17:09:43 2018 +0200
@@ -86,6 +86,10 @@
 		return
 	}
 
+	if jr.Code == 0 {
+		jr.Code = http.StatusOK
+	}
+
 	rw.Header().Set("Content-Type", "application/json")
 	rw.WriteHeader(jr.Code)
 	if err := json.NewEncoder(rw).Encode(jr.Result); err != nil {