2016-05-14 12:31:43 +02:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2016-05-14 13:21:10 +02:00
|
|
|
"net/http"
|
|
|
|
"encoding/json"
|
2016-05-14 12:31:43 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func jsonOutput(w http.ResponseWriter,data interface{}){
|
2016-05-14 13:21:10 +02:00
|
|
|
js, err := json.Marshal(data)
|
|
|
|
if err != nil {
|
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
}
|
2016-05-14 12:31:43 +02:00
|
|
|
|
2016-05-14 13:21:10 +02:00
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
w.Write(js)
|
2016-05-14 12:31:43 +02:00
|
|
|
}
|