yanic/api/lib.go

18 lines
311 B
Go
Raw Normal View History

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