diff pkg/controllers/token.go @ 979:7934b5c1a910

Finally enqueue sounding result import job to import jobs. Sends back the id of the job.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 19 Oct 2018 12:14:53 +0200
parents d9dbb6139760
children a244b18cb916
line wrap: on
line diff
--- a/pkg/controllers/token.go	Thu Oct 18 18:37:19 2018 +0200
+++ b/pkg/controllers/token.go	Fri Oct 19 12:14:53 2018 +0200
@@ -10,13 +10,6 @@
 	"gemma.intevation.de/gemma/pkg/models"
 )
 
-func sendJSON(rw http.ResponseWriter, data interface{}) {
-	rw.Header().Set("Content-Type", "application/json")
-	if err := json.NewEncoder(rw).Encode(data); err != nil {
-		log.Printf("error: %v\n", err)
-	}
-}
-
 func renew(rw http.ResponseWriter, req *http.Request) {
 	token, _ := auth.GetToken(req)
 	newToken, err := auth.Sessions.Renew(token)
@@ -44,7 +37,7 @@
 		Roles:   session.Roles,
 	}
 
-	sendJSON(rw, &result)
+	SendJSON(rw, http.StatusOK, &result)
 }
 
 func logout(rw http.ResponseWriter, req *http.Request) {
@@ -96,5 +89,5 @@
 		Roles:   session.Roles,
 	}
 
-	sendJSON(rw, &result)
+	SendJSON(rw, http.StatusCreated, &result)
 }