func (api *Api) appUpdate(rw http.ResponseWriter, r *http.Request, user *account.User) { app, err := account.FindAppByClientId(mux.Vars(r)["client_id"]) if err != nil { handleError(rw, err) return } _, err = findTeamAndCheckUser(app.Team, user) if err != nil { handleError(rw, err) return } if err := json.NewDecoder(r.Body).Decode(&app); err != nil { handleError(rw, errors.ErrBadRequest) return } // It is not allowed to change the client id yet. app.ClientId = mux.Vars(r)["client_id"] err = app.Update() if err != nil { handleError(rw, err) return } Ok(rw, app) }
func (api *Api) appDelete(rw http.ResponseWriter, r *http.Request, user *account.User) { app, err := account.FindAppByClientId(mux.Vars(r)["client_id"]) if err != nil { handleError(rw, err) return } if err = app.Delete(*user); err != nil { handleError(rw, err) return } Ok(rw, app) }
func (api *Api) appInfo(rw http.ResponseWriter, r *http.Request, user *account.User) { app, err := account.FindAppByClientId(mux.Vars(r)["client_id"]) if err != nil { handleError(rw, err) return } _, err = findTeamAndCheckUser(app.Team, user) if err != nil { handleError(rw, err) return } Ok(rw, app) }