func MarshalledBytes(m Model) ([]byte, error) { r, err := data.Marshal(m) if err != nil { return nil, err } return ioutil.ReadAll(r) }
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) } }