Example #1
0
func (ctl *controller) updateGroup(c web.C, w http.ResponseWriter, r *http.Request) {
	group := api.Group{}
	if err := json.NewDecoder(r.Body).Decode(&group); err != nil {
		logger.Error("updateGroup", "error", err)
		http.Error(w, http.StatusText(400), 400)
		return
	}
	group.ID = c.URLParams["group_id"]
	group.ApplicationID = c.URLParams["app_id"]

	err := ctl.api.UpdateGroup(&group)
	switch err {
	case nil:
	default:
		logger.Error("updateGroup", "error", err, "group", group)
		http.Error(w, http.StatusText(400), 400)
		return
	}

	groupJSON, err := ctl.api.GetGroupJSON(group.ID)
	if err != nil {
		logger.Error("updateGroup", "error", err, "groupID", group.ID)
		http.Error(w, http.StatusText(400), 400)
		return
	}

	w.Write(groupJSON)
}
Example #2
0
File: api.go Project: sangba/im
func joinGrp(w http.ResponseWriter, r *http.Request) {
	grp := api.Group{}
	grp.JoinGrp(w, r)
}
Example #3
0
File: api.go Project: sangba/im
func addgrp(w http.ResponseWriter, r *http.Request) {
	grp := api.Group{}
	grp.AddGrp(w, r)
}
Example #4
0
File: api.go Project: sangba/im
func mems(w http.ResponseWriter, r *http.Request) {
	grp := api.Group{}
	grp.Mems(w, r)
}
Example #5
0
File: api.go Project: sangba/im
func mygrp(w http.ResponseWriter, r *http.Request) {
	grp := api.Group{}
	grp.MyGrp(w, r)
}