func AddContactReceiver(rw http.ResponseWriter, req *http.Request, params martini.Params, enc encoding.Encoder) string { var err error cr := contact.ContactReceiver{ FirstName: req.FormValue("first_name"), LastName: req.FormValue("last_name"), Email: req.FormValue("email"), } types := req.FormValue("contact_types") typeArray := strings.Split(types, ",") for _, t := range typeArray { var ct contact.ContactType ct.ID, err = strconv.Atoi(t) if err != nil { apierror.GenerateError("Trouble getting contact type ID", err, rw, req) } cr.ContactTypes = append(cr.ContactTypes, ct) } if err := cr.Add(); err != nil { apierror.GenerateError("Trouble adding contact receiver", err, rw, req) } return encoding.Must(enc.Encode(cr)) }