diff controllers/json.go @ 240:9012e4045da4

Implemented /user delete controller.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 26 Jul 2018 17:56:02 +0200
parents 713234a04a87
children 3b688fe04c39
line wrap: on
line diff
--- a/controllers/json.go	Thu Jul 26 17:15:22 2018 +0200
+++ b/controllers/json.go	Thu Jul 26 17:56:02 2018 +0200
@@ -90,9 +90,13 @@
 		jr.Code = http.StatusOK
 	}
 
-	rw.Header().Set("Content-Type", "application/json")
+	if jr.Code != http.StatusNoContent {
+		rw.Header().Set("Content-Type", "application/json")
+	}
 	rw.WriteHeader(jr.Code)
-	if err := json.NewEncoder(rw).Encode(jr.Result); err != nil {
-		log.Printf("error: %v\n", err)
+	if jr.Code != http.StatusNoContent {
+		if err := json.NewEncoder(rw).Encode(jr.Result); err != nil {
+			log.Printf("error: %v\n", err)
+		}
 	}
 }