Esempio n. 1
0
func (a *ApplicationController) UpdateApplicationHandler(c *gin.Context) {
	appId := c.MustGet("app").(JSON)["_id"]
	d := db.NewAppsDbService(c.MustGet("user").(string))
	doc := utils.WhitelistFields([]string{"name"}, utils.GetBody(c))

	err := d.Update(JSON{
		"_id": appId,
	}, JSON{
		"$set": doc,
	})

	if err != nil {
		RestError(c, err)
		return
	}
}
Esempio n. 2
0
func (a *ApplicationController) UpdateApplicationHandler(w rest.ResponseWriter, r *rest.Request) {
	appId := r.PathParam("appId")
	db := neutrino.NewAppsDbService(r.Env["user"].(string))
	doc := utils.WhitelistFields([]string{"name"}, utils.GetBody(r))

	err := db.Update(bson.M{
		"_id": appId,
	}, bson.M{
		"$set": doc,
	})

	if err != nil {
		RestError(w, err)
		return
	}

	w.WriteHeader(http.StatusOK)
}