func AddUnitsHandler(w http.ResponseWriter, r *http.Request, u *auth.User) error { n, err := numberOfUnitsOrError(r) if err != nil { return err } appName := r.URL.Query().Get(":name") app, err := getApp(appName, u) if err != nil { return err } return app.AddUnits(n) }
func addUnits(w http.ResponseWriter, r *http.Request, t *auth.Token) error { n, err := numberOfUnits(r) if err != nil { return err } appName := r.URL.Query().Get(":app") u, err := t.User() if err != nil { return err } app, err := getApp(appName, u) if err != nil { return err } return app.AddUnits(n) }
func addUnits(w http.ResponseWriter, r *http.Request, t *auth.Token) error { n, err := numberOfUnits(r) if err != nil { return err } appName := r.URL.Query().Get(":app") u, err := t.User() if err != nil { return err } rec.Log(u.Email, "add-units", "app="+appName, fmt.Sprintf("units=%d", n)) app, err := getApp(appName, u) if err != nil { return err } return app.AddUnits(n) }
func addUnits(w http.ResponseWriter, r *http.Request, t *auth.Token) error { n, err := numberOfUnits(r) if err != nil { return err } appName := r.URL.Query().Get(":app") u, err := t.User() if err != nil { return err } rec.Log(u.Email, "add-units", "app="+appName, fmt.Sprintf("units=%d", n)) app, err := getApp(appName, u) if err != nil { return err } err = app.AddUnits(n) if _, ok := err.(*quota.QuotaExceededError); ok { return &errors.HTTP{ Code: http.StatusForbidden, Message: err.Error(), } } return err }