Beispiel #1
0
func MarshalledBytes(m Model) ([]byte, error) {
	r, err := data.Marshal(m)
	if err != nil {
		return nil, err
	}

	return ioutil.ReadAll(r)
}
Beispiel #2
0
func httpWriteMarshal(w http.ResponseWriter, out interface{}) {
	rdr, err := data.Marshal(out)
	if err != nil {
		http.Error(w, "error serializing", http.StatusInternalServerError)
		return
	}

	_, err = io.Copy(w, rdr)
	if err != nil {
		http.Error(w, "Error writing response.", http.StatusInternalServerError)
	}
}