示例#1
0
func platformRemove(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	canDeletePlatform := permission.Check(t, permission.PermPlatformDelete)
	if !canDeletePlatform {
		return permission.ErrUnauthorized
	}
	name := r.URL.Query().Get(":name")
	return app.PlatformRemove(name)
}
示例#2
0
// title: remove platform
// path: /platforms/{name}
// method: DELETE
// responses:
//   200: Platform removed
//   401: Unauthorized
//   404: Not found
func platformRemove(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	canDeletePlatform := permission.Check(t, permission.PermPlatformDelete)
	if !canDeletePlatform {
		return permission.ErrUnauthorized
	}
	name := r.URL.Query().Get(":name")
	err := app.PlatformRemove(name)
	if err == app.ErrPlatformNotFound {
		return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
	}
	return err
}
示例#3
0
文件: platform.go 项目: tsuru/tsuru
// title: remove platform
// path: /platforms/{name}
// method: DELETE
// responses:
//   200: Platform removed
//   401: Unauthorized
//   404: Not found
func platformRemove(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	r.ParseForm()
	canDeletePlatform := permission.Check(t, permission.PermPlatformDelete)
	if !canDeletePlatform {
		return permission.ErrUnauthorized
	}
	name := r.URL.Query().Get(":name")
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypePlatform, Value: name},
		Kind:       permission.PermPlatformDelete,
		Owner:      t,
		CustomData: event.FormToCustomData(r.Form),
		Allowed:    event.Allowed(permission.PermPlatformReadEvents),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	err = app.PlatformRemove(name)
	if err == app.ErrPlatformNotFound {
		return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
	}
	return err
}
示例#4
0
func platformRemove(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	name := r.URL.Query().Get(":name")
	return app.PlatformRemove(name)
}