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