Mercurial > gemma
diff pkg/controllers/json.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 | 8bb2e48e2dfd |
children | a244b18cb916 |
line wrap: on
line diff
--- a/pkg/controllers/json.go Thu Oct 18 18:37:19 2018 +0200 +++ b/pkg/controllers/json.go Fri Oct 19 12:14:53 2018 +0200 @@ -121,3 +121,11 @@ } } } + +func SendJSON(rw http.ResponseWriter, code int, data interface{}) { + rw.Header().Set("Content-Type", "application/json") + rw.WriteHeader(code) + if err := json.NewEncoder(rw).Encode(data); err != nil { + log.Printf("error: %v\n", err) + } +}